WEBVTT

00:00.990 --> 00:06.210
In this video we learn how to create two dimensional scatter plots so scatter plots are specifically

00:06.210 --> 00:10.530
useful to detect the relationships between two numerical features.

00:10.770 --> 00:16.680
So for example in our Titanic dataset we have the numerical features aids and fair.

00:16.920 --> 00:22.710
And by creating a set up plot for these two features we might get a first visual impression whether

00:22.710 --> 00:26.400
there is a relationship between these two factors.

00:26.400 --> 00:32.970
So for example our hypothesis might be that older passengers have more money and therefore pay a higher

00:32.970 --> 00:40.430
ticket price so we will see this in a minute but first of all let's import pandas and we import met

00:40.430 --> 00:51.600
plot lip and we are using the Seabourn style and then we are working with the Titanic dataset and now

00:51.630 --> 00:58.200
if you want to create a scatter plot for the Titanic data frame we can call here the plot method and

00:58.200 --> 01:03.320
instead of passing here a line to the kind parameter we can pass scatter

01:06.390 --> 01:08.480
and now let's press shift type here.

01:08.550 --> 01:11.810
So here we have the parameters X and Y.

01:12.030 --> 01:19.070
And here we have to determine which columns should be on the x axis and its column on the y axis.

01:19.340 --> 01:26.880
And here and our example we want to have the H column on the x axis so we pass here the H column to

01:26.880 --> 01:35.260
the parameter X and within quotation marks here and on the y axis we want to have the column

01:37.980 --> 01:41.570
and we also set the figure size to 15 8.

01:41.880 --> 01:44.700
And now we can run any of the code

01:47.550 --> 01:53.730
and here we can see the scatter plot for the H and the fact column and actually use a single dot to

01:53.870 --> 01:55.380
set us a passenger.

01:55.380 --> 01:57.790
So for example here we have a peasant.

01:57.870 --> 02:06.360
That is the 64 year old and the peasants are paid actually about two hundred sixty or seventy a ticket

02:06.360 --> 02:07.270
price.

02:07.380 --> 02:12.900
And so we have five peasants this year where we have an on missing values in the fair and each column

02:13.290 --> 02:18.980
one dot or one scatter a year and apparently both a very first inspection.

02:19.350 --> 02:26.730
It's quite hard to detect yet any relationship So our hypothesis was that the older the peasants the

02:26.730 --> 02:28.380
higher the ticket price.

02:28.410 --> 02:34.830
So if our hypothesis holds true then we would actually expect to get us from the bottom left to the

02:34.860 --> 02:35.620
top right.

02:36.090 --> 02:42.300
But this is actually hard to confirm visually and in this case you would need to perform some more advanced

02:42.420 --> 02:49.560
statistical analysis so let's move on with our plot and actually we can determine the color of the US

02:49.590 --> 03:00.200
and we can do this with the parameter C and we can pass flight sample red and that's also a Pyramid

03:00.220 --> 03:06.180
where we can change the type of the dots are the shadows here and this is called marker

03:08.880 --> 03:12.720
and the default setting is that that year we have a kind of a round dot.

03:12.750 --> 03:17.070
So the default setting here is this kind here.

03:18.390 --> 03:29.420
So we can see nothing has changed but we can also change the marker for example to the OR to uppercase

03:29.430 --> 03:38.050
X or to a lower case x and then we get here actually.

03:38.060 --> 03:43.820
Different scatters and also we can change the size of the scatter scene with the paired meter.

03:43.830 --> 03:48.900
As far for size and t we can pass in.

03:48.970 --> 03:51.180
So for example let's try to find.

03:52.280 --> 03:58.500
And we can also increase the size by increasing the integers for example to 50.

04:00.170 --> 04:03.700
And now we have four x three here a larger scatters.

04:03.740 --> 04:05.590
So now let's go back here to 20th

04:10.510 --> 04:17.110
and that's actually one more future where we can transform our two dimensional scatter plot into a three

04:17.110 --> 04:24.280
dimensional scatter plot and we can do this by passing here to the color perimeter another column of

04:24.280 --> 04:25.390
the data frame.

04:25.390 --> 04:28.120
And if you pass here these left column

04:32.690 --> 04:39.110
then we get here for the dots of the scatters the different colors depending whether the corresponding

04:39.110 --> 04:42.080
passenger survived or not survived.

04:42.080 --> 04:48.440
So for example the peasant so here has a white color and white color XY means here a zero in these survival

04:48.470 --> 04:52.430
column which means that this passenger did not survive.

04:52.430 --> 04:56.460
So in the end we can say that here we have a three dimensional graph.

04:56.510 --> 04:59.560
So the first dimension is here the x axis AIDS.

04:59.990 --> 05:04.480
Then we have the bi axis fair and we have the color.

05:04.490 --> 05:08.400
It gives us information about the the passengers survived or not.

05:08.900 --> 05:16.250
And we can also change the color style here of the survive column and this the pyramid color map.

05:20.480 --> 05:26.260
And if we a look at the map plug the page then here we can see some color style.

05:26.270 --> 05:32.560
So we have a video this my inferno Mama and some more here.

05:32.690 --> 05:40.120
So let's get to see a video of this and we possibly read this here as a string

05:42.900 --> 05:44.190
and it's running the sir.

05:45.150 --> 05:49.160
And here we can see that we have successfully changed the color map.

05:49.530 --> 05:56.180
So now yellow stands for survived and the dark color for not survived.

05:56.190 --> 06:00.920
So again in this last column we only have two different values zero and one.

06:00.930 --> 06:06.340
And therefore we have only dots scatters that are dark or yellow.

06:06.360 --> 06:10.470
But let's try also here the column peak class

06:16.170 --> 06:21.510
and here we can see now that we have dots scatters with three different colors.

06:21.510 --> 06:24.400
So we have for the third class the yellow.

06:24.450 --> 06:27.440
Then we have for the second class green.

06:27.630 --> 06:32.210
And for the first class we have here kind of a dark color.

06:32.370 --> 06:38.230
And here we can see visually that the first class hasn't just paid to the highest ticket prices.

06:38.250 --> 06:42.110
So we have fear the dark shadows or dark plots here at the top.

06:42.240 --> 06:48.240
Then we have the second class with the green dots here in the middle and then at the bottom we have

06:48.240 --> 06:51.760
actually the yellow dots for the third class.

06:52.140 --> 06:57.580
And actually the relationship between H and P classes the less intuitive.

06:57.810 --> 07:04.680
However one could to conclude actually that the very young passengers here are more likely to be in

07:04.680 --> 07:13.120
the second or third class and the older passengers are actually more likely to be first class passengers.

07:13.140 --> 07:13.560
All right.

07:13.560 --> 07:18.150
This was the video on scatter plots and I hope to see you also in the next video by.
