WEBVTT - This file was automatically generated by VIMEO

0
00:00:07.760 --> 00:00:12.420
Hi. In this video we will learn how to work with cells and how to execute code.

1
00:00:14.840 --> 00:00:17.140
Now let's create a new empty python notebook.

2
00:00:25.470 --> 00:00:28.810
We are now in the edit mode of the first empty cell.

3
00:00:29.150 --> 00:00:33.570
We can recognize it by this green border and also by this icon.

4
00:00:35.080 --> 00:00:38.490
When we press escape, we'll get into the command mode

5
00:00:40.130 --> 00:00:43.680
and the border is now blue Press enter again,

6
00:00:43.900 --> 00:00:45.640
and we are in the added mode again.

7
00:00:46.750 --> 00:00:49.180
Let's import the pandas package with

8
00:00:52.590 --> 00:00:56.740
shift enter, you execute current cell and move into the next cell.

9
00:01:00.890 --> 00:01:03.310
Now let's process the variable names.

10
00:01:26.170 --> 00:01:29.310
We have now all the lines in the file in a list,

11
00:01:29.690 --> 00:01:33.550
and we are interested only in the part with the variable names.

12
00:01:34.300 --> 00:01:38.400
And these are starting with, uh, the list index of 33.

13
00:01:47.830 --> 00:01:51.450
Now let's extract only this part with the variable name. Uh,

14
00:01:51.450 --> 00:01:53.130
this is the part before the colon.

15
00:01:54.250 --> 00:01:57.510
And let's create a new variable for this called call names

16
00:02:13.810 --> 00:02:18.210
alt Enter. You execute current cell and a new MT cell below will be created.

17
00:02:27.920 --> 00:02:32.220
Now we have one thing missing, and this is the last column, uh,

18
00:02:32.220 --> 00:02:36.820
which basically should tell us if the email was marked as spam or not.

19
00:02:38.520 --> 00:02:40.420
So let's append this to this list.

20
00:02:54.330 --> 00:02:56.580
Okay, and this is exactly what you wanted.

21
00:03:04.130 --> 00:03:06.500
Next, I would like to show you, uh,

22
00:03:06.690 --> 00:03:09.340
some useful shortcuts on how to word these cells.

23
00:03:13.610 --> 00:03:17.670
Uh, we can, uh, move the cells up and down. You just select, uh,

24
00:03:17.880 --> 00:03:22.500
thumb cell one or more cells. When you want to select more cells,

25
00:03:22.530 --> 00:03:27.150
just press, uh, shift and use your arrows or mouse.

26
00:03:29.700 --> 00:03:32.210
Mouse. And with this button, we can move it up or down.

27
00:03:35.090 --> 00:03:36.230
Now we can, uh,

28
00:03:36.290 --> 00:03:40.830
do basic operations with the cells like copying them the shortcut.

29
00:03:40.890 --> 00:03:44.860
For this C in the command mode, press C

30
00:03:47.720 --> 00:03:50.180
and now press B. To paste it,

31
00:03:50.920 --> 00:03:52.740
we can cut the cells

32
00:03:56.360 --> 00:03:57.460
and PIs them below.

33
00:04:03.990 --> 00:04:08.140
Uh, when you press double D, uh, the cell will be deleted

34
00:04:12.360 --> 00:04:16.730
when you press A, a new T cell above will be created

35
00:04:18.680 --> 00:04:22.290
when you press b and t cell below will be created.

36
00:04:28.350 --> 00:04:33.130
And one useful thing is, uh, to change the type of the cells,

37
00:04:33.470 --> 00:04:35.810
uh, we will use only markdown or code.

38
00:04:36.030 --> 00:04:41.000
The shortcut for this are m for markdown or y for code.

39
00:04:51.050 --> 00:04:55.230
We can also execute, um, whole notebook, for example.

40
00:04:55.370 --> 00:04:58.350
Now let's open the command palette with P

41
00:05:00.720 --> 00:05:02.180
and we can run all cells.

42
00:05:13.160 --> 00:05:16.820
We can execute, just, uh, just cut.

43
00:05:17.200 --> 00:05:21.940
We can execute just parts of the notebook. Now, for example,

44
00:05:22.190 --> 00:05:26.060
let's execute the part, uh, below the current cell.

45
00:05:27.050 --> 00:05:28.340
Open the command palette.

46
00:05:35.870 --> 00:05:39.720
Give your option to run all cells about or run all cells below.

47
00:05:44.820 --> 00:05:48.480
We also see here on the left this number,

48
00:05:48.780 --> 00:05:53.380
and this is basically the order in which the cells were executed.

49
00:05:59.130 --> 00:06:02.830
Now let's read our data file into pandas data frame.

50
00:06:03.570 --> 00:06:08.430
We can do it very easily using pandas, uh, method called Read, C s,

51
00:06:08.470 --> 00:06:09.303
V,

52
00:06:28.810 --> 00:06:32.150
and we can print the first few rows with the head method.

53
00:06:39.500 --> 00:06:42.040
Now let's add the column names to this data frame.

54
00:06:57.110 --> 00:07:01.320
Okay, we have now our data frame prepared just to check, uh,

55
00:07:01.390 --> 00:07:03.120
what is the shape of this data frame.

56
00:07:07.290 --> 00:07:12.150
Our data frame has 58 columns and 4,601 rows.

57
00:07:15.660 --> 00:07:20.540
Let's do the correlation analysis of our dataset. What is correlation?

58
00:07:21.620 --> 00:07:26.510
Correlation measures the strength of a linear relationship between

59
00:07:26.830 --> 00:07:30.410
variables. It can be in a range of minus one,

60
00:07:30.430 --> 00:07:35.300
and one value of one indicates strongest positive relationship.

61
00:07:36.010 --> 00:07:40.100
That means when one variable increases, the other one increases as well.

62
00:07:41.410 --> 00:07:44.260
Zero indicates no relationship at all,

63
00:07:45.280 --> 00:07:48.260
and minus one indicates negative relationship.

64
00:07:49.340 --> 00:07:53.110
That means when one variable increases, the other one decreases.

65
00:07:56.010 --> 00:08:00.710
To get correlations for each pair of the variables is very easy. In pandas,

66
00:08:00.730 --> 00:08:03.230
we just use data frame dot core method.

67
00:08:13.050 --> 00:08:17.510
We have now our correlation data frame, but let's assign it to a variable

68
00:08:30.160 --> 00:08:34.780
to make some conclusions when seeing just the data frame is a little bit

69
00:08:34.900 --> 00:08:36.290
tedious. Uh,

70
00:08:36.310 --> 00:08:41.050
but we can make it much easier to read using a heat map and

71
00:08:41.300 --> 00:08:44.020
we can make it with plotly expressed. But first,

72
00:08:44.080 --> 00:08:47.540
we have to install the plotly package into our base environment.

73
00:08:48.760 --> 00:08:49.990
Let's open our terminal.

74
00:09:07.870 --> 00:09:12.030
Okay, Plotly is installed. We have to import it.

75
00:09:12.770 --> 00:09:14.830
We will use Plotly express for it.

76
00:09:30.540 --> 00:09:32.960
And this is the syntax to plot the heat map.

77
00:09:51.570 --> 00:09:56.340
Now we have overview of the whole dataset on

78
00:09:56.500 --> 00:10:01.020
X axis. Uh, we have variable names, same as on the Y axis.

79
00:10:01.640 --> 00:10:03.900
In the middle we see a yellow line,

80
00:10:04.440 --> 00:10:09.420
but this is because the correlation of a variable of it itself is one.

81
00:10:10.380 --> 00:10:14.200
When we hover over the chat, we can see a popup,

82
00:10:14.200 --> 00:10:17.960
which tells us the exact names of the variables and the correlation value.

83
00:10:18.660 --> 00:10:23.460
We see that the correlation values are shown as a color gradient.

84
00:10:24.240 --> 00:10:26.940
Uh, yellow means strong positive correlation,

85
00:10:27.160 --> 00:10:29.660
and the dark blue are negative correlations.

86
00:10:31.740 --> 00:10:34.380
Ly charts are interactive, so we can zoom in.

87
00:10:36.340 --> 00:10:39.160
Now let's, for example, zoom in into this part, uh,

88
00:10:39.260 --> 00:10:42.160
of the dataset where the correlations are higher,

89
00:10:52.840 --> 00:10:56.700
and, uh, how to interpret the correlations in our case. Uh,

90
00:10:56.700 --> 00:11:00.940
when the correlation is higher between, uh, the occurrences of these two words.

91
00:11:01.320 --> 00:11:04.660
For example, the occurrence of word laps and telnet.

92
00:11:06.270 --> 00:11:06.630
Uh,

93
00:11:06.630 --> 00:11:11.450
the higher occurrences of one word means higher occurrence of the other word in

94
00:11:11.450 --> 00:11:15.010
the email as well, but there is no other relationship.

95
00:11:19.630 --> 00:11:21.610
We double click, uh, using Zoom out.

96
00:11:24.130 --> 00:11:27.270
In our next video, we will learn how to work with markdown.
