WEBVTT

00:01.130 --> 00:06.560
In this video we learn how to create joint plots under aggression plots and this these plots we can

00:06.560 --> 00:12.950
graphically analyze whether that's a positive or negative functional relationship between features.

00:12.950 --> 00:15.040
So for example now a titanic Dead set.

00:15.060 --> 00:21.580
There are the features age and fair and we could try to answer the question whether for example overlap

00:21.710 --> 00:25.630
hasn't just pay more than a young gap has themselves for that tickets.

00:25.640 --> 00:31.990
And in this video we will also further graphically analyze whether the age or the fare of the passenger

00:32.000 --> 00:36.280
had influence on the chance to survive the disaster.

00:36.290 --> 00:40.210
So first of all its import pandas see born and met plot slip.

00:40.490 --> 00:45.680
And again we are working with our Titanic data set and explain our Titanic data set.

00:45.680 --> 00:52.760
We have two numerical columns to continuous numerical columns H and fair and in a that we can create

00:52.790 --> 00:59.960
a joint plot which is actually a setup plot where we have on the exact CIS the age and on the y axis

01:00.080 --> 01:03.560
be fair and kind of the plot.

01:03.560 --> 01:07.180
We can pass yes get the plot so you want get a scatter plot

01:11.430 --> 01:17.670
and we can see on the x axis that the AIDS and on the y axis the fair and each single the dots here

01:17.670 --> 01:19.880
are each single point to say a passenger.

01:20.190 --> 01:25.490
And here at the top end on the right hand side we can also see the frequency distribution.

01:25.860 --> 01:32.370
So this is the frequency distribution or histogram for the fair and this is the the histogram for the

01:32.370 --> 01:33.030
H.

01:33.510 --> 01:38.820
So we can see that the majority of ages are here around between 20 and 40.

01:39.300 --> 01:43.410
And for the fare here around between zero and 50.

01:43.680 --> 01:49.800
And also here we have a future warning which is caused by an intersection between the side pi packets

01:50.190 --> 01:51.720
and the Seabourn package.

01:51.720 --> 01:55.750
So we can ignore this here and actually most of the apparently to hide.

01:55.770 --> 02:04.590
We can determine here the size and the height of the graph and we can also change the kind of the plot.

02:04.590 --> 02:07.770
So instead of having a scatter plot we can have different plots slow.

02:07.770 --> 02:09.120
Let's check this here.

02:12.060 --> 02:19.730
A.B. has the option to pass get a regression or is the delta KDE or hex so let's pass here hex

02:25.160 --> 02:29.820
and hex stands for a hex bin plot and here we can see that our blood are here.

02:29.840 --> 02:36.530
The area is divided into two equal size Texas guns and the darker the color of the aspect affects like

02:36.530 --> 02:39.560
on the more data points we have here.

02:39.590 --> 02:45.230
So here we can see the majority of data points that we have here at the quiet.

02:45.320 --> 02:54.810
Low fat prizes and at ages between 20 and thirty eight or something and we can also pass here K D E

03:00.600 --> 03:07.570
and Katie U stands for kind of density estimates or so he has set off having a histogram BFM kernel

03:07.620 --> 03:15.390
density estimate or kind of a line that approximates the histogram and you know a graph you can see

03:15.390 --> 03:23.790
actually some areas and the darker the areas the more data points we have fear so he can identify where

03:23.850 --> 03:26.920
the majority of data points are located.

03:26.920 --> 03:29.460
All right now let's go back to the scatter plot

03:36.090 --> 03:42.150
so here we can see the scatter plot between H and fair and the next question would be whether there

03:42.150 --> 03:46.340
is a significant relationship between age and fair.

03:46.350 --> 03:52.590
So for example of the old hasn't just paid more than younger passengers and we can answer this question

03:52.590 --> 03:57.630
by having a regressive plot and therefore we can also pass the Rick

04:02.690 --> 04:09.350
and TB can see a regression line through the data points and the regression line seems to be upward

04:09.350 --> 04:17.080
sloping so here we have a positive relationship or a correlation between the H future and the fast feet.

04:17.540 --> 04:23.870
So the older the peasants are the higher the ticket price and you can also see here the shaded area

04:24.110 --> 04:31.880
around the regression line and this marks actually the a 95 percent confidence interval of the regression

04:31.880 --> 04:32.560
line.

04:32.660 --> 04:39.970
So the regression line itself is actually a point estimate and let's assume that V is statistically

04:40.220 --> 04:48.170
similar to the booking for the Titanic 1000 times then in 95 percent of all cases the regression line

04:48.200 --> 04:51.470
between H and fair is in this area here.

04:51.530 --> 04:59.000
So it seems like that the positive slope or positive relationship is statistically significant here

04:59.600 --> 05:05.980
and seaborne actually provides some alternatives to create a regression plot with some y functionality

05:06.680 --> 05:10.220
and for example we can do this with a l m plot.

05:10.340 --> 05:14.870
So again here we pass them our Titanic data frame to the parameter data.

05:15.080 --> 05:23.780
Then we want to f on the exact S H on the y axis fair and with the parameters aspect and height we can

05:23.780 --> 05:28.040
determine externally the size of the plot or the subplots.

05:28.040 --> 05:30.240
So we will see this in a minute.

05:30.290 --> 05:31.040
Let's run here

05:34.030 --> 05:40.480
so essentially we have actually the same regressive plot with the same regression line and the confidence

05:40.500 --> 05:41.240
in time.

05:42.130 --> 05:43.360
So let's have a look here.

05:48.000 --> 05:53.560
So again here we have parameters like CIA which stands for the confidence interval.

05:54.240 --> 05:59.370
So here in this confidence interval here we have a 95 percent confidence.

05:59.370 --> 06:06.400
And under the hood seaborne actually simulates the booking of the Titanic 1000 times.

06:06.480 --> 06:11.580
And by doing so it creates a confidence interval for the regression line.

06:11.580 --> 06:19.180
So this is the same as above but actually here the alleged plot provides some additional functionality.

06:19.590 --> 06:26.760
And also here we have the parameter hue and we can split up our data frame for example by the sex column

06:32.260 --> 06:39.310
so we can see that we have categorized all single points or dots as being either male or female.

06:39.730 --> 06:47.230
And here we have female with blue collar and for the the dots points we have one regression line and

06:47.230 --> 06:49.980
also for the females we have fun regression line.

06:50.110 --> 06:57.970
And it seems like that for males and females the positive relationship is serious statistically significant.

06:58.000 --> 07:04.910
So we have an upward sloping regression line and instead of having here both the regression lines and

07:05.080 --> 07:12.280
on the graph we can also create subplots and we can do this and the set of passing of the sex column

07:12.280 --> 07:21.090
to the parameters you can posit to the pair meet meat columns Carlo and by doing so they're creating

07:21.090 --> 07:23.940
a two subplots and actually two columns.

07:24.360 --> 07:32.190
So here we have the regression plot for the male peasant us and your father female passengers and both

07:32.460 --> 07:41.380
seems to be actually here upward sloping and theoretically we can also create subplots in rows by passing

07:41.390 --> 07:47.760
year sex to the rows pairing meta.

07:47.830 --> 07:49.700
So now we have two rows.

07:49.750 --> 07:54.790
We have the regression father made a peasants us and for the female peasants us.

07:55.120 --> 07:56.310
But let's stick here.

07:56.320 --> 07:57.180
Two columns

08:00.230 --> 08:06.600
and two bits of the pyramids aspect and height we can actually customize the size of them the subplots

08:06.600 --> 08:07.580
here.

08:07.770 --> 08:13.980
So here we might conclude that there is a positive relationship between H and fair not only for the

08:14.000 --> 08:16.960
male peasant does but also for the female peasant us.

08:17.190 --> 08:23.520
And now we want to analyse the factors that actually influence them the chance to survive.

08:23.520 --> 08:27.100
And again we are creating here an adolescent plot.

08:27.180 --> 08:31.470
Then on the x axis our first factor is the age.

08:31.650 --> 08:38.640
And then on the y axis we have our survival column so far this survival column we know that we only

08:38.640 --> 08:43.130
have the values that 0 and 1 and let's running.

08:43.200 --> 08:52.490
So so here on the x axis we can see the eight and on the y axis we have either zeros or ones.

08:52.490 --> 08:54.690
And here we have a regression line.

08:54.690 --> 09:00.860
But here we have a so-called logistic regression because our dependent variable here.

09:00.870 --> 09:07.600
So the survived by our are but it's actually a categorical feature maybe either half the value says

09:07.620 --> 09:15.180
0 and 1 and therefore we have to set he had the logistic Parramatta to true because here we want to

09:15.180 --> 09:17.610
perform a logistic regression

09:28.290 --> 09:29.190
so now we can see here.

09:29.190 --> 09:36.090
I want to just stick regression line and we can see that it's the downward sloping and I see the confidence

09:36.120 --> 09:41.360
intervals the chest that this might be statistically significant.

09:41.370 --> 09:47.610
So the older the peasant sir the lower so the chance to survive and the vice versa.

09:47.610 --> 09:52.330
So the younger the peasants the higher the survival rate the chance to survive.

09:52.410 --> 09:56.550
And this is actually in line with that women tend to run fast.

09:56.550 --> 10:03.360
So children had a better chance to survive than older passengers and also here we can make a categorical

10:03.360 --> 10:10.020
split so we can split our data frame into groups and therefore we can pass the Flex hopper to the.

10:10.150 --> 10:13.290
Para meta a categorical variable.

10:13.500 --> 10:15.180
So for example the six

10:26.080 --> 10:32.780
so here we have the logistic regression between H and survived form a peasant us and female peasant.

10:33.130 --> 10:36.990
And it looks like that here we have a difference.

10:37.120 --> 10:43.770
So if I'm a peasant says it seems like the angle of the and so the higher the chance to survive.

10:44.170 --> 10:49.330
And for female peasants us the relationship is actually the other way around.

10:49.570 --> 10:52.850
So that could mean that form a peasant does.

10:53.080 --> 10:56.510
It was even more important to be a child.

10:56.620 --> 10:57.120
All right.

10:57.130 --> 11:02.770
Next year we can do the same analysis also here split it by the PE class.

11:02.800 --> 11:10.090
So we have still here on the x axis that the H and on Devi axis these survived column and then we split

11:10.120 --> 11:13.000
our date data frame by that peak plus column

11:15.860 --> 11:16.520
and again here.

11:16.520 --> 11:20.130
This is a logistic regression SVM funded by axis.

11:20.240 --> 11:25.270
The survive feature but the categorical data zero of one.

11:25.280 --> 11:29.510
So we have to pass here true to the logistic parameter

11:32.150 --> 11:34.570
so true with capital T of course

11:40.950 --> 11:48.860
and here we can see the logistic regression for the three passenger classes between H and survived.

11:49.050 --> 11:55.470
And it seems to that for all three passenger classes the relationship holds true that the order the

11:55.470 --> 12:00.560
passenger the lower the chance to survive the disaster.

12:00.680 --> 12:01.100
All right.

12:01.100 --> 12:06.530
This was the the video on regression lines and this is pretty helpful to visualize relationships between

12:06.540 --> 12:07.400
their features.

12:07.670 --> 12:14.960
So now we understand better the factors that influence actually the chance to survive for the Titanic

12:14.960 --> 12:16.150
disaster.

12:16.400 --> 12:18.970
And with this we are finished here and out to sea.

12:18.970 --> 12:20.870
Also in the next video by.
