1
00:00:00,250 --> 00:00:00,890
All right.

2
00:00:01,110 --> 00:00:04,530
Now I've done a little bit of EDTA or exploratory data analysis.

3
00:00:04,540 --> 00:00:09,150
We're going to do one more step and that is building a correlation matrix.

4
00:00:09,180 --> 00:00:12,000
You might be thinking what is a correlation matrix.

5
00:00:12,240 --> 00:00:18,510
In layman's terms it's a big table of numbers telling us how each independent variable is related to

6
00:00:18,510 --> 00:00:18,860
each other.

7
00:00:18,890 --> 00:00:19,650
Okay.

8
00:00:19,710 --> 00:00:20,600
These columns here.

9
00:00:20,610 --> 00:00:22,610
How do they interact with each other.

10
00:00:22,620 --> 00:00:27,240
Are they a positive correlation or they are negative correlation.

11
00:00:27,240 --> 00:00:29,850
Let's not talk about it for much longer because we want to see it.

12
00:00:29,850 --> 00:00:31,680
We want to see what is happening.

13
00:00:31,830 --> 00:00:39,420
So let's go make a correlation matrix and to do so we can use DFT score.

14
00:00:39,600 --> 00:00:46,710
We hit shift tab here compute power wise correlation of columns excluding and a slash null values.

15
00:00:46,710 --> 00:00:53,100
Well power wise correlation fascist basically saying Compare each of these columns to each other.

16
00:00:53,550 --> 00:00:56,430
Well let's see it in action.

17
00:00:56,790 --> 00:01:00,930
If you're looking at this for the first time quite confusing because there's a lot of numbers going

18
00:01:00,930 --> 00:01:02,320
on here okay.

19
00:01:02,340 --> 00:01:11,140
You can see the columns are on the rows as well as the columns and the diagonal here is 1 1 1 1.

20
00:01:11,190 --> 00:01:15,450
There's a lot of decimals and some are negative and some are positive.

21
00:01:16,040 --> 00:01:20,430
What we might do though instead of staring at this and exploring it for a little bit we might make this

22
00:01:20,430 --> 00:01:29,660
a little bit more visual so let's make our correlation matrix a little prettier.

23
00:01:29,670 --> 00:01:35,610
We're going to do that using C Bond's heat map so we'll set it up in a variable so call matrix equals

24
00:01:35,610 --> 00:01:36,110
DFT.

25
00:01:36,120 --> 00:01:36,860
Cool.

26
00:01:37,020 --> 00:01:37,980
Wonderful.

27
00:01:38,160 --> 00:01:45,220
And then we'll set up a figure and an ax using what is a penalty not subplots.

28
00:01:45,270 --> 00:01:50,250
That's a fig size I kind of know the fig size because I've seen this pop before.

29
00:01:50,280 --> 00:02:00,620
So I want it to be 15 width and height and then we're going to go X equals s and s dot heat map would

30
00:02:00,620 --> 00:02:06,440
help if I typed map and then I'm gonna pass it call matrix and we want to annotate it so we'll set a

31
00:02:06,440 --> 00:02:08,770
not to equal true.

32
00:02:09,110 --> 00:02:13,340
And we also want a line with line weights.

33
00:02:13,370 --> 00:02:16,720
Yeah I believe that set of zero point five.

34
00:02:17,170 --> 00:02:18,390
And then what else do we need.

35
00:02:18,400 --> 00:02:21,860
There was a couple more things format equals we only got two decimal places.

36
00:02:21,880 --> 00:02:26,020
So see here these like six so twos two is gonna be enough for us.

37
00:02:26,620 --> 00:02:33,070
And then see map to give it some nice colors will go yellow green blue.

38
00:02:33,760 --> 00:02:34,150
Wonderful.

39
00:02:34,180 --> 00:02:35,490
Let's let's check it out.

40
00:02:35,710 --> 00:02:38,140
Invalid syntax Oh forget the comma here.

41
00:02:38,140 --> 00:02:41,250
Classic Wonderful.

42
00:02:41,320 --> 00:02:41,910
Okay.

43
00:02:41,980 --> 00:02:43,290
So what is this showing us.

44
00:02:43,330 --> 00:02:49,990
We've got some cut off things here that's that pesky map plot lib three point one point one area.

45
00:02:50,080 --> 00:02:50,500
That's right.

46
00:02:50,500 --> 00:02:52,390
We can fix it so might go bottom.

47
00:02:52,390 --> 00:02:56,020
You might not see that if you're using a lighter version of that plot lib then what I'm using at the

48
00:02:56,020 --> 00:03:03,770
moment we need to adjust the y axis limitations so we're going to get Y lamb.

49
00:03:04,420 --> 00:03:05,080
Wonderful.

50
00:03:05,080 --> 00:03:12,130
And then we're going to go X still set y land that's that's it that's how we change it we to move the

51
00:03:12,130 --> 00:03:16,120
bottom up and we want to move the top down.

52
00:03:16,280 --> 00:03:17,470
That makes sense.

53
00:03:17,470 --> 00:03:23,950
So bottom plots zero point five and top minus zero point four.

54
00:03:23,950 --> 00:03:32,090
Does this work wonderful that's looking a little bit better it's not cut off and this little adjustment

55
00:03:32,090 --> 00:03:36,560
here this is from the research that I found by just just searching for it.

56
00:03:36,560 --> 00:03:46,640
So map plot lib seaborne first I think that my history might have had it there plot lib There we go

57
00:03:47,180 --> 00:03:48,850
first and last row cut off.

58
00:03:49,190 --> 00:03:52,420
That's an example of searching for your problem when you have it right.

59
00:03:52,430 --> 00:03:55,330
When you run into an issue it's just about trying to figure it out.

60
00:03:55,430 --> 00:04:01,280
So they've got a similar problem to what we just had cut off and then come down here you can find this

61
00:04:01,280 --> 00:04:05,510
is the lines of code that I'm using here and in fact they're making a correlation matrix as well.

62
00:04:05,540 --> 00:04:07,350
Beautiful yeah.

63
00:04:07,440 --> 00:04:11,970
Unfortunately map plot lib three point one point one broke seaborne heat maps.

64
00:04:12,120 --> 00:04:13,020
Well that's all right.

65
00:04:13,020 --> 00:04:15,600
We've got our heat map we've got our correlation matrix.

66
00:04:15,600 --> 00:04:20,660
Again this is just the same version of this a more visual format.

67
00:04:20,770 --> 00:04:26,690
I look at this and I understand this one a lot better than I do this one.

68
00:04:26,740 --> 00:04:28,600
So what is actually going on here.

69
00:04:28,600 --> 00:04:31,660
Well we can see on the diagonal we've got a lot of one values.

70
00:04:31,690 --> 00:04:38,140
But what this means the diagonal is we might zoom out one tick so we can see the diagonal.

71
00:04:38,200 --> 00:04:44,500
Is giving a perfect correlation which means the age column is exactly equal to the age column which

72
00:04:44,500 --> 00:04:46,610
makes a whole bunch of sense right.

73
00:04:46,690 --> 00:04:54,310
And the sex column is completely equal to the sex column and so on and so on so on all the way down

74
00:04:54,850 --> 00:04:56,120
the diagonal here.

75
00:04:56,320 --> 00:05:01,500
But then we have some other a lot of other actually little cells here.

76
00:05:01,660 --> 00:05:08,950
We can see on the side you got 0 up to 1 and some of them are positive like this one here.

77
00:05:09,160 --> 00:05:18,320
And some of them a negative we just compared chest pain type which was C.P. to our target.

78
00:05:18,320 --> 00:05:19,400
Let's investigate that.

79
00:05:19,400 --> 00:05:21,560
What's the correlation here.

80
00:05:21,570 --> 00:05:22,700
I got C P.

81
00:05:23,290 --> 00:05:26,460
It's got a positive correlation so zero point for three.

82
00:05:26,460 --> 00:05:28,110
Remember the maximum value is 1.

83
00:05:28,270 --> 00:05:29,730
But this is telling us how.

84
00:05:29,740 --> 00:05:34,610
Chest pain is related to the target column.

85
00:05:34,710 --> 00:05:39,030
Well if we're looking at this and we did some research on a correlation matrix I'm going to tell you

86
00:05:39,030 --> 00:05:45,600
because I've done this research myself a higher positive value means a potential positive correlation

87
00:05:46,500 --> 00:05:52,290
and a higher negative value means a potential negative correlation or a decrease.

88
00:05:52,290 --> 00:06:00,690
What this is saying is as C.P. goes up the target value also increases now.

89
00:06:00,700 --> 00:06:02,110
Does that make sense.

90
00:06:02,380 --> 00:06:06,880
If we come up here so if we look at this plot that we did before.

91
00:06:07,010 --> 00:06:12,230
So as CPI goes up the target value also increases.

92
00:06:12,230 --> 00:06:19,540
So remember our target value is 0 0 1 0 for no disease 1 for disease now were most interested here in

93
00:06:19,540 --> 00:06:26,920
the correlation because if you looked at there's no disease is highest at zero so that means no disease

94
00:06:27,040 --> 00:06:28,110
the target is zero.

95
00:06:28,210 --> 00:06:30,030
And chest pain type is also zero.

96
00:06:30,690 --> 00:06:31,490
Okay.

97
00:06:31,510 --> 00:06:39,830
So according to our correlation matrix as C.P. goes up because it's a positive correlation the target

98
00:06:39,830 --> 00:06:41,090
value should also go up.

99
00:06:41,090 --> 00:06:43,610
So let's investigate disease.

100
00:06:43,610 --> 00:06:45,550
This is a 1 value and this is 0.

101
00:06:45,830 --> 00:06:48,740
So blue is one salmon is zero.

102
00:06:48,800 --> 00:06:49,160
Salmon.

103
00:06:49,160 --> 00:06:53,200
What a beautiful color as our chest pain type goes up 0 1 2 3.

104
00:06:53,210 --> 00:07:01,220
Does the blue column for one of target value go up if we look here it does go up slightly and this drops

105
00:07:01,220 --> 00:07:09,920
off dramatically and then it goes up here it goes down here but the ratio of disease to no disease is

106
00:07:09,920 --> 00:07:11,000
still much higher.

107
00:07:11,810 --> 00:07:17,320
So that's where the positive correlation comes from it comes from chest pain type increasing or LCP

108
00:07:17,450 --> 00:07:25,400
column as that increases our target column meaning disease or no disease also increases.

109
00:07:25,460 --> 00:07:29,810
So that's a positive correlation that's why it's positive here.

110
00:07:29,900 --> 00:07:35,280
Now let's have a look at one of the negative columns so you've got a negative correlation here.

111
00:07:35,280 --> 00:07:39,120
It's about the same ratio but just in a negative way.

112
00:07:39,120 --> 00:07:46,890
That means if we look here x sang we'll check our data dictionary for that in a second as X and goes

113
00:07:46,890 --> 00:07:48,420
down.

114
00:07:48,420 --> 00:07:55,520
So should the target value let's not take this correlation matrix word for let's reproduce this plot

115
00:07:55,940 --> 00:08:00,530
except using the x and column of what we do that we might jump up here.

116
00:08:00,800 --> 00:08:08,290
What is X Ang exercise induced and Gina if you wondering what and Gina is we've checked out that before

117
00:08:08,640 --> 00:08:10,740
a condition marked by severe pain in the chest.

118
00:08:10,810 --> 00:08:19,960
So this means that if you exercise do you get hot pain and let's have a look exercise induced angina

119
00:08:20,280 --> 00:08:23,260
one equals yes zero equals no.

120
00:08:23,380 --> 00:08:28,650
So do you get hot pain when you exercise if you do.

121
00:08:28,810 --> 00:08:29,730
That's a one.

122
00:08:29,890 --> 00:08:35,740
And if you don't that's a zero there's a negative correlation according to our correlation matrix I'm

123
00:08:35,770 --> 00:08:37,620
saying correlation a lot I know.

124
00:08:39,160 --> 00:08:42,030
So X sang compared to the target value.

125
00:08:42,190 --> 00:08:46,560
Do they have disease or not is negatively correlated.

126
00:08:46,560 --> 00:08:53,900
That means as X and goes down the target should also go down.

127
00:08:53,920 --> 00:08:59,260
Now there's only two values here for each of these so this is actually a pretty straightforward example.

128
00:08:59,290 --> 00:09:05,710
So if we think about this based off what you've heard about in terms of heart disease if someone was

129
00:09:05,710 --> 00:09:10,210
telling you that when they exercise they get chest pain so they would have one.

130
00:09:10,510 --> 00:09:18,300
Would you predict closer to someone having heart disease or not if they had exercised induced chest

131
00:09:18,300 --> 00:09:19,650
pain.

132
00:09:19,650 --> 00:09:27,240
What would you be more inclined do they have heart disease or they don't well for me I would be more

133
00:09:27,240 --> 00:09:34,020
inclined to say well based off the rest of the data if they're getting exercised induced chest pain

134
00:09:34,380 --> 00:09:36,260
it could be something going on with their heart right.

135
00:09:36,270 --> 00:09:37,670
They could be heart disease.

136
00:09:37,920 --> 00:09:39,840
So this is where there's a negative correlation.

137
00:09:39,840 --> 00:09:42,710
This is where the negative correlation comes into play.

138
00:09:42,750 --> 00:09:51,270
Let's go down here back to our correlation matrix there's a negative correlation of negative point for

139
00:09:51,270 --> 00:09:51,800
4.

140
00:09:52,400 --> 00:09:57,650
So that means as X and goes down the target value goes down.

141
00:09:57,650 --> 00:10:03,950
Based off what the call function is seeing in our data exercised induced angina when I compare that

142
00:10:03,950 --> 00:10:09,530
column to the target column I'm noticing that when X Ang is lower.

143
00:10:09,530 --> 00:10:13,050
So is the target column based off what we're looking here.

144
00:10:13,070 --> 00:10:17,840
It's and remember it's only a point 4 4 correlation it's not a perfect want like negative 1 correlation

145
00:10:18,380 --> 00:10:20,960
but just it's trending towards.

146
00:10:20,960 --> 00:10:30,100
If someone didn't have chest pain so didn't have exercised induced angina the trend is negative.

147
00:10:30,290 --> 00:10:35,620
So it's trending towards them not having heart disease does that make sense.

148
00:10:35,770 --> 00:10:37,950
And you could go through all of these values.

149
00:10:38,070 --> 00:10:41,420
So this is pretty flat like this is almost basically zero.

150
00:10:41,420 --> 00:10:44,840
There is no correlation between FBI s and the target.

151
00:10:45,450 --> 00:10:52,940
While our data dictionary telling us FBI s so fasting blood sugar so this is saying is the fasting blood

152
00:10:52,940 --> 00:10:56,440
sugar above 120 milligrams per deciliter.

153
00:10:56,450 --> 00:10:59,040
I believe that might be deciliter one of those shoes Eric was false.

154
00:10:59,330 --> 00:11:02,020
So let's basically saying they're perfectly even.

155
00:11:02,060 --> 00:11:06,100
There's no real positive or negative correlation it just it is what it is.

156
00:11:06,200 --> 00:11:12,410
And so that's the kind of insight that you can start to form with this correlation matrix and that's

157
00:11:12,410 --> 00:11:18,500
a kind of insight that we want to sort of figure out on our own if we want medical experts and we could

158
00:11:18,500 --> 00:11:20,970
only work with the data that we have.

159
00:11:21,020 --> 00:11:22,350
This is the purpose of ADFA.

160
00:11:22,370 --> 00:11:27,860
This is the purpose of what we've gone through here comparing different variables looking at the distribution

161
00:11:28,990 --> 00:11:31,060
comparing more different variables here.

162
00:11:31,360 --> 00:11:34,620
And this process we could keep going with this Ryan.

163
00:11:34,660 --> 00:11:42,660
We can keep going until we really really understand the data but what we want to do next is model driven

164
00:11:42,690 --> 00:11:43,590
EDTA.

165
00:11:43,620 --> 00:11:52,080
So what that means is building a machine learning model to derive insights of how these independent

166
00:11:52,080 --> 00:11:55,950
variables here contribute to the target variable.

167
00:11:55,980 --> 00:12:01,110
Now correlation matrix is one of them but we're more interested in trying to predict for the future

168
00:12:01,110 --> 00:12:03,900
the correlation matrix only deals with the data that we have.

169
00:12:03,900 --> 00:12:09,480
We're more interested in building a machine learning model that has predictive power based on the data

170
00:12:09,630 --> 00:12:12,750
that we have to predict on things in the future.

171
00:12:12,780 --> 00:12:14,930
So that's what we're going to look at next.

172
00:12:15,150 --> 00:12:18,810
If you a little bit stuck here of what the correlation matrix is.

173
00:12:18,810 --> 00:12:24,930
Don't worry it's a pretty in-depth concept too to understand but where you can probably go next is by

174
00:12:24,930 --> 00:12:28,810
just searching what is a correlation matrix.

175
00:12:28,890 --> 00:12:29,900
So you're here.

176
00:12:30,030 --> 00:12:32,030
What is a correlation matrix.

177
00:12:32,040 --> 00:12:36,660
You could go to this first link a correlation matrix is a table showing correlation coefficients between

178
00:12:36,720 --> 00:12:37,880
variables.

179
00:12:37,890 --> 00:12:42,400
Well that sounds like a good resource start to read up on a little bit more.

180
00:12:42,510 --> 00:12:48,780
That looks a little bit like with the graph that we made but we've covered most of the crux of a correlation

181
00:12:48,780 --> 00:12:49,660
matrix.

182
00:12:49,710 --> 00:12:51,090
It's really just going.

183
00:12:51,090 --> 00:12:51,600
Okay.

184
00:12:51,690 --> 00:12:57,540
Looking at two variables and going is the relationship positive a.k.a. as one increases so does the

185
00:12:57,540 --> 00:12:58,060
other.

186
00:12:58,200 --> 00:13:05,110
Or is the relationship negative as one decreases so does the other but let's have a look at our workflow

187
00:13:05,110 --> 00:13:10,300
see where we're up to we've been through some data analysis now it's time to get onto the machine learning

188
00:13:10,310 --> 00:13:11,440
in the modeling section.

189
00:13:11,560 --> 00:13:13,420
Let's see where we're up to here.

190
00:13:13,420 --> 00:13:18,100
If we look at our new project workflow we've covered this we've looked at some exploratory data analysis

191
00:13:18,100 --> 00:13:20,120
using num pie pan as a map plot lib.

192
00:13:20,260 --> 00:13:25,070
Now it's time to get into the machine learning part of things using psychic learning.

193
00:13:25,150 --> 00:13:30,340
We'll start to test our little theories about how what we found out an exploratory data analysis we'll

194
00:13:30,340 --> 00:13:34,690
start to see does our machine learning model agree with what we've found here.

195
00:13:34,690 --> 00:13:36,280
Just exploring the data on Alan.
