Python for the .NET developer Transcripts
Chapter: Computational notebooks
Lecture: A more interactive example
0:00 Well, I'm pretty happy with
0:01 this little program that
0:02 does the Python Bytes domain reference authority
0:05 let's go ahead and save that and
0:07 we can stop it from running.
0:09 I want to do something more
0:10 interesting and more interactive, and
0:12 there's some cool examples on the
0:13 Jupiter notebook page so we're going to just
0:16 grab one of those and put them up here.
0:17 So, because this is local
0:20 I could just go to the trajectory
0:21 and drop the files but if for some reason
0:22 it's like a server type thing
0:24 it will even let me upload stuff over there.
0:26 So let's put some files there.
0:29 I'll take this and this.
0:30 Those two files need to be uploaded
0:34 so we're going to run this Lorenz Notebook.
0:36 And notice it has a lorenz.py
0:38 in the notebook, you can have these
0:40 Python helper files or libraries
0:43 that then you reference in your notebook.
0:45 So that's what's going to happen here.
0:48 And notice we have the Lorenz differential equations
0:50 and it let's us explore how these work.
0:52 So let's start by running this. We have ipywidgets
0:57 it looks like we have them installed
0:58 that's cool. And here, we can run this, nothing happens
1:01 but if we double click it, notice
1:03 this is, I believe this is Luteic here.
1:05 You define exactly like the right math
1:08 and all that, like that's pretty awesome.
1:10 I used to live in that world, don't live there anymore.
1:13 Don't know how to do it, but it is pretty cool.
1:16 So we can come down here and import
1:18 oh this is not so good.
1:21 We're just missing scipy here.
1:22 So, no problem. Let's go and fix that.
1:25 We have the right environment so
1:26 pip install scipy.
1:31 Cool! Let's try to run this code again.
1:33 Here we go! All right, that looks like it worked.
1:37 Aw, perfect. Look at that graph!
1:39 It actually took it a second to compute it
1:40 but that is so cool. I love how that looks.
1:44 Now we can change these numbers
1:47 and it will change the graph.
1:48 Like if I put a .1, or yeah
1:51 a 10 instead of 50, notice how different that is.
1:54 We can put these back, good.
1:56 That picture there.
1:58 But it turns out that there's actually
2:00 much more interactivity that we can get out of this.
2:03 Let's go over here, shut this down for a second.
2:06 Seven, apparently, is not going to shut it down.
2:09 And let's run those extension management
2:11 things I showed you earlier.
2:13 We have Node, all right we have Node 12.12 installed.
2:17 I don't know if that's the latest
2:19 but it's pretty close to the latest.
2:21 I'm going to have Jupiter, envi extension enabled
2:23 the widgets, okay so that looks like it works.
2:27 The other thing we have to do is set up this lab
2:30 extension here. This one could take a moment.
2:35 Whew! That took probably almost a minute.
2:37 But now we can just rerun Jupiter lab.
2:41 Start running our way down these.
2:45 And check this out, now when we run it
2:47 we get this cool interactivity.
2:49 Remember we were playing with the sigma
2:50 but now what if I put it like that?
2:52 What if I do it like that?
2:53 What if I change beta when it's this?
2:54 And the row, right. Row kind of scales it.
2:57 So we'll go like that, and you know
2:59 the sigma is way too big. It looks more good like that.
3:02 The beta is a little small. Isn't that cool?
3:07 So now, not only can we set up these graphs
3:09 and explore these datas, but we can put filtrine
3:12 and adjusting of the variables
3:14 and create these interactive solvers.
3:17 That is so cool, right?
3:18 I told you these were very different
3:20 than the kind of applications you might build
3:22 that just play with data as an app
3:24 a command like thing that will just process some data.
3:27 No, these are, these are quite different all right?
3:29 And maybe this takes a while to compute
3:31 and we can just play with it.
3:32 But down here we can go do a little bit more work.
3:35 These are the current arguments past to it
3:39 from up here, right? That's 340 right there
3:45 351 right there.
3:47 So we can then take what you do with the slider
3:50 and then go do further work, all right.
3:51 So I can go, 'oh, let's go do some calculation
3:53 on the shape,' and we can even import
3:56 Marplot Lib again and then do some graphs.
3:59 Right, and the way it looks, probably has something
4:02 to do with the little sliders we spun.
4:04 Here we go! Really really cool.
4:05 Here's a much more interactive notebook
4:08 at exploring the Lorenz differential equations.
4:11 Love it!