Python for .NET Developers Transcripts
Chapter: Computational notebooks
Lecture: A more interactive example

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

Talk Python's Mastodon Michael Kennedy's Mastodon