WEBVTT - This file was automatically generated by VIMEO

0
00:00:07.710 --> 00:00:08.510
Hi.

1
00:00:08.510 --> 00:00:13.370
In this video we will learn how to make our notebooks interactive with IPI

2
00:00:13.370 --> 00:00:14.203
widget.

3
00:00:14.690 --> 00:00:19.020
Jupyter Widgets are interactive browser controls for Jupyter notebooks,

4
00:00:19.250 --> 00:00:23.260
like basic form controls like sliders, check boxes,

5
00:00:23.770 --> 00:00:27.020
text inputs, patterns, combo boxes, and others.

6
00:00:28.180 --> 00:00:31.800
It can be container controls like taps, accordions,

7
00:00:32.250 --> 00:00:35.080
horizontal or vertical layout boxes and so on.

8
00:00:35.980 --> 00:00:40.200
And also advanced controls like maps two D or three D

9
00:00:40.200 --> 00:00:42.560
visualizations, data grids and others.

10
00:00:44.240 --> 00:00:49.110
There are core and custom jupyter widgets and you can explore them more from the

11
00:00:49.350 --> 00:00:51.190
provided links in the references section.

12
00:00:52.950 --> 00:00:57.770
Now we will create a section where we will plot in the same scatter plot like we

13
00:00:57.770 --> 00:00:59.370
all already did in our notebook.

14
00:00:59.950 --> 00:01:03.330
So the scatter plot with two variables from our dataset,

15
00:01:03.870 --> 00:01:08.850
but we'll have the option to select X and the Y variable from our Jupyter

16
00:01:08.850 --> 00:01:09.683
widget,

17
00:01:10.250 --> 00:01:14.530
specifically with a combo box and the option to fit the regression with a simple

18
00:01:14.530 --> 00:01:15.363
checkbox.

19
00:01:18.230 --> 00:01:21.140
Let's import our classes first. We

20
00:01:29.290 --> 00:01:30.890
will need the combo box,

21
00:01:31.140 --> 00:01:34.410
horizontal box checkbox and interactive output.

22
00:01:39.070 --> 00:01:41.780
Let's create a new section called IPI widget.

23
00:01:50.010 --> 00:01:52.230
And now I will paste here the code

24
00:01:57.280 --> 00:01:58.540
and let's explain it.

25
00:02:01.330 --> 00:02:03.100
Here we create our widgets.

26
00:02:04.560 --> 00:02:08.900
The first two are the combo boxes to filter x, and the y variable

27
00:02:14.040 --> 00:02:18.590
value is the first value, uh, which is shown when the widget launches

28
00:02:21.950 --> 00:02:26.000
placeholder. This is a text when the combo box is empty.

29
00:02:27.610 --> 00:02:30.120
These are the options for us to select from.

30
00:02:30.790 --> 00:02:35.460
This is the text, uh, which is shown next to the widget.

31
00:02:38.460 --> 00:02:43.440
And if Azure option is true, then in order to execute the code,

32
00:02:43.670 --> 00:02:45.200
some value must be selected.

33
00:02:50.580 --> 00:02:55.370
It is basically the same for the other combo box. And, um,

34
00:02:55.700 --> 00:02:58.530
let's explain the plot regression function

35
00:03:01.450 --> 00:03:02.940
here, recreate our chart,

36
00:03:07.460 --> 00:03:12.320
and here we are fitting the regression model based on the value of the checkbox.

37
00:03:14.670 --> 00:03:16.890
We align our controls horizontally,

38
00:03:18.730 --> 00:03:22.670
and then we connect our plotting function with the widgets

39
00:03:24.060 --> 00:03:26.400
and we display the output. Let's run it.

40
00:03:34.280 --> 00:03:38.300
We see that our chart is nicely plotted. Uh, widgets are visible.

41
00:03:45.170 --> 00:03:46.640
Let's change one variable,

42
00:03:48.820 --> 00:03:52.280
and you see that the plot is automatically refreshed.

43
00:03:55.340 --> 00:03:56.370
Let's try this one.

44
00:04:01.360 --> 00:04:06.350
And the regression, this is working as well.

45
00:04:10.320 --> 00:04:13.130
Unfortunately, when we export this file,

46
00:04:13.400 --> 00:04:15.770
this functionality is not preserved, uh,

47
00:04:15.770 --> 00:04:20.570
because the plotting requires running python kernel because we execute Python

48
00:04:20.640 --> 00:04:23.850
code, but we can save widget state,

49
00:04:24.190 --> 00:04:28.290
and this is plotted in the exported file. Let's see, how does it look like?

50
00:04:29.710 --> 00:04:32.410
Go to widgets, save notebook, widget, state,

51
00:04:35.120 --> 00:04:38.890
save the notebook, and let's export this to H T M L.

52
00:04:49.660 --> 00:04:52.040
We see here the plot, also the widgets,

53
00:04:53.830 --> 00:04:56.170
but when we change the values, nothing will happen.

54
00:05:03.030 --> 00:05:05.690
As you can see, Jupyter gets with the widgets.

55
00:05:05.690 --> 00:05:09.090
Very powerful when you start exploring them. Uh,

56
00:05:09.220 --> 00:05:13.370
start with the method to interact, uh, which is, uh, very easy to use as well.

57
00:05:16.400 --> 00:05:20.820
In our next video, we will turn our notebook into a dashboard with voa.
