1
00:00:00,930 --> 00:00:05,130
Now, here, we will first create or classify an object.

2
00:00:05,220 --> 00:00:09,070
Then we fit to what extent and why train return to that object.

3
00:00:09,210 --> 00:00:14,700
And then we will predict the values of are able using that classifier object.

4
00:00:17,280 --> 00:00:26,010
So those steps are the same as creating a regression tree on their differences in regulation.

5
00:00:26,400 --> 00:00:32,200
We were calling B.S. and Creeley gracer, but for classifier, we have to coalition declassify it.

6
00:00:35,670 --> 00:00:39,480
Again, we are naming this object as our classification tree.

7
00:00:39,540 --> 00:00:41,430
So we are writing CLV, KRI.

8
00:00:41,670 --> 00:00:42,870
This is a very weird name.

9
00:00:42,870 --> 00:00:45,420
You can select your own variable name if you want.

10
00:00:46,840 --> 00:00:50,520
And in the parameters we are passing maximum bet this tree.

11
00:00:51,930 --> 00:00:56,940
Few want to look at all the other parameters that you can pass in this function.

12
00:00:57,270 --> 00:01:05,160
You can head chef PEB and if you remember, we discussed the criteria's such as classification added

13
00:01:05,330 --> 00:01:08,600
Ragini and Cross and Croppy by default.

14
00:01:09,010 --> 00:01:11,640
And this function takes Gini as a criteria.

15
00:01:13,620 --> 00:01:19,260
If you want to test this tree using Crosson, Groppi or any other criteria.

16
00:01:19,290 --> 00:01:22,530
You can just replace Deani with those criteria.

17
00:01:24,540 --> 00:01:30,840
Again, we are taking Max depth as three if you do not provide this boundary condition.

18
00:01:31,620 --> 00:01:36,390
You will get a very large tree which will probably overfit your train data.

19
00:01:37,860 --> 00:01:45,180
But just to easily use relays or KRI, we are first taking maximum depth of three.

20
00:01:45,870 --> 00:01:50,870
Later on we can play with this parameter to get our optimal degree.

21
00:01:52,200 --> 00:01:55,920
We are not providing minimum sample, split and minimum and beliefs.

22
00:01:57,150 --> 00:01:59,850
So let's clear this classifier object.

23
00:02:00,900 --> 00:02:06,090
Next, we will fed this classifier object using our Ekstrand, NY Trin variable.

24
00:02:08,960 --> 00:02:11,610
So our classification tree is ready.

25
00:02:13,100 --> 00:02:21,710
We can predict why train NYC best values using this classification tree and we can corridor predict

26
00:02:21,840 --> 00:02:22,480
my third.

27
00:02:23,800 --> 00:02:24,970
To prayer values.

28
00:02:27,610 --> 00:02:30,760
So we just need to right see a live tree.

29
00:02:31,070 --> 00:02:32,420
There is a classified object.

30
00:02:32,730 --> 00:02:35,330
And we are calling Daudt predict Mentone.

31
00:02:36,340 --> 00:02:41,200
And as an argument, we are providing X strain and expense data.

32
00:02:43,180 --> 00:02:44,290
Let's run this.

33
00:02:45,370 --> 00:02:47,980
Now we have our very good values.

34
00:02:48,010 --> 00:02:52,640
And Wyandotte score tests underscore pride and why underscore Krein underscore Prag.

35
00:02:53,740 --> 00:02:57,580
Let's look at the values of why underscored that Sunday school pride.

36
00:02:59,050 --> 00:03:03,990
You can see we are getting zero one zero one values for our test to.

37
00:03:07,640 --> 00:03:14,740
Now, in regression, we used artist Squirter and MFC to calculate the performance of the model for

38
00:03:14,740 --> 00:03:15,940
classification models.

39
00:03:15,970 --> 00:03:19,180
We can use accuracy, score and confusion metrics.

40
00:03:20,710 --> 00:03:27,340
Accuracy is scored is the percentage of records that we can correctly identify.

41
00:03:28,030 --> 00:03:29,890
Using our model.

42
00:03:32,550 --> 00:03:40,980
So, for example, accuracy of 60 percent means we can correctly identify 60 percent off for viral use

43
00:03:41,040 --> 00:03:42,000
using our model.

44
00:03:47,790 --> 00:03:53,060
First, we will create the confusion matrix for what crane data said.

45
00:03:54,090 --> 00:03:58,880
So if you had to shift tab here, you first have to provide the crew and lose of way.

46
00:03:59,490 --> 00:04:02,140
And then you have to grade the data values of why.

47
00:04:06,850 --> 00:04:15,100
So our crew value is environ, the school train and our predicted values is and why underscore Krein

48
00:04:15,130 --> 00:04:15,860
underscore correct.

49
00:04:16,090 --> 00:04:17,230
So I will run this.

50
00:04:18,720 --> 00:04:26,950
So whenever you call the confusion metrics, you will get this kind of metrics that rose to represent

51
00:04:27,910 --> 00:04:29,320
the actual values.

52
00:04:30,700 --> 00:04:34,060
And the columns represent the predicted values.

53
00:04:34,720 --> 00:04:36,430
And these are categories.

54
00:04:37,060 --> 00:04:38,590
So this is four zero.

55
00:04:39,130 --> 00:04:40,210
This is for one.

56
00:04:41,380 --> 00:04:45,160
And this first column here is for CEDO category.

57
00:04:45,280 --> 00:04:48,640
And the second column is for one category.

58
00:04:50,290 --> 00:04:56,830
So this first story present actual zero and the second row represent actual one.

59
00:04:57,520 --> 00:05:04,030
This first column represent credit trade zero and the second column represent credit trade one.

60
00:05:06,250 --> 00:05:15,760
So we have 172 observations, which were actually zero, and our predicted value is also zero.

61
00:05:18,190 --> 00:05:25,600
This 172 is also known, this grew negative, since actually they are negative or zero, and we are

62
00:05:25,720 --> 00:05:36,820
also predicting ripping them as zero, therefore crude negative here for this 176 that grew value is

63
00:05:36,820 --> 00:05:37,150
one.

64
00:05:37,390 --> 00:05:41,920
Since this is in the second row and the predicted value is zero.

65
00:05:43,390 --> 00:05:49,810
These are known as false negative since we are crediting this as negatives.

66
00:05:50,560 --> 00:05:56,460
But actually they're positive or one for this 14.

67
00:05:56,560 --> 00:05:58,750
The actual value is zero or negative.

68
00:05:59,620 --> 00:06:03,610
But we are treating them as one or positive.

69
00:06:06,570 --> 00:06:09,600
These are also known as false positives, and these are.

70
00:06:10,270 --> 00:06:10,830
Positive.

71
00:06:11,430 --> 00:06:12,910
The actual value is also one.

72
00:06:13,050 --> 00:06:15,510
And we are also predicting it as one.

73
00:06:17,900 --> 00:06:24,830
So from this confusion metrics, you can say that we are predicting this to do right and this 92 right.

74
00:06:25,160 --> 00:06:28,610
And we are not able to predict this one, 26 and 14.

75
00:06:29,150 --> 00:06:33,410
So accuracy scores should be 172 plus 92.

76
00:06:34,550 --> 00:06:38,300
That is 264 divided by the total number of observation.

77
00:06:38,330 --> 00:06:39,920
That is four zero four.

78
00:06:42,050 --> 00:06:47,480
But you can also calculate the accuracy score by just calling accuracy score from Escandon metrics.

79
00:06:48,530 --> 00:06:53,360
Now let's take a look at total confusion metrics for our test dataset.

80
00:06:56,570 --> 00:07:03,920
Again, the roads represent actual values and columns represent projected values.

81
00:07:03,950 --> 00:07:05,600
So these are crew positive.

82
00:07:06,090 --> 00:07:08,010
Dacula Lewis zero.

83
00:07:08,180 --> 00:07:13,130
And we also predicted it as zero for this segment in the actual value is one.

84
00:07:13,190 --> 00:07:16,600
And we also protect 17 observations as well.

85
00:07:18,050 --> 00:07:25,420
You can find the accuracy score by just calling the function accuracy under score score and the role.

86
00:07:25,460 --> 00:07:28,570
So you have to provide grew a loose and uprated values.

87
00:07:28,790 --> 00:07:33,470
So we are providing why underscore tests and why underscore test and that score predict.

88
00:07:35,510 --> 00:07:39,920
You can see the accuracy for our model is around 55 percent.

89
00:07:41,000 --> 00:07:45,870
It is not great, but with some tuning we can improve.

90
00:07:45,890 --> 00:07:46,670
This is skort.

91
00:07:48,490 --> 00:07:50,400
Now, let's applaud this decision tree.

92
00:07:52,390 --> 00:07:56,530
The matter the same, the cold sort of same here.

93
00:07:56,560 --> 00:07:59,900
Just earlier we were using Greg KRI sense.

94
00:08:00,040 --> 00:08:01,630
That was our model here.

95
00:08:01,630 --> 00:08:06,880
We just have to use CNF Cree since our classification model is Silveri.

96
00:08:10,230 --> 00:08:16,890
We are using feature name as extranet or columns, since we can access our column information using

97
00:08:16,890 --> 00:08:19,240
this attribute of our extended frame.

98
00:08:20,070 --> 00:08:27,510
And we are passing this column names as a feature name so that we can see the actual column values in

99
00:08:27,510 --> 00:08:28,050
our tree.

100
00:08:29,160 --> 00:08:37,290
And since we won conditional formatting in our tree, we are calling fairly equated to just run this

101
00:08:37,290 --> 00:08:41,130
for cells to get our tree.

102
00:08:45,330 --> 00:08:48,270
Here, each cell contain four values.

103
00:08:49,050 --> 00:08:50,550
First one is the condition.

104
00:08:51,450 --> 00:09:01,330
So our first split is on budget column and the value at which they spertus taking place is 30000, 694.

105
00:09:04,110 --> 00:09:06,480
Next, we have the genie value for this bucket.

106
00:09:07,290 --> 00:09:14,230
Next, we have the total sample size that is falling under this bucket since this is our top.

107
00:09:15,300 --> 00:09:19,350
We have all our observations in this note, which is equal to four hundred and four.

108
00:09:20,160 --> 00:09:22,290
Then we have the distribution of values.

109
00:09:22,560 --> 00:09:27,570
So there are 186 zeros and two one eight ones in this bucket.

110
00:09:28,050 --> 00:09:29,850
The total should be four hundred and four.

111
00:09:32,170 --> 00:09:35,510
So after our first split of this condition is true.

112
00:09:36,100 --> 00:09:37,950
We are going into this branch.

113
00:09:38,230 --> 00:09:41,950
And if our condition is false, we are going into this branch.

114
00:09:42,580 --> 00:09:45,040
Then further, we are dividing this cell.

115
00:09:45,430 --> 00:09:47,980
On this condition, that is production expense.

116
00:09:49,270 --> 00:09:53,170
And here for this bucket, the genie is zero point one five seven.

117
00:09:53,260 --> 00:09:55,470
The total sample size is today, five.

118
00:09:56,590 --> 00:09:59,830
So today, five observations.

119
00:10:01,180 --> 00:10:09,340
Are satisfying this condition and the rest 369 are falling under this bucket and they are not satisfying

120
00:10:09,360 --> 00:10:10,080
this condition.

121
00:10:11,760 --> 00:10:16,620
Here, the values again represent the distribution of zeros and ones.

122
00:10:16,830 --> 00:10:20,940
There are three zeros and there are 32 ones in this book.

123
00:10:22,230 --> 00:10:26,220
And the color here represent the purity of that bucket.

124
00:10:27,270 --> 00:10:30,200
Blue represent high purity of ones.

125
00:10:30,550 --> 00:10:35,880
So since today, two observations, although 35 observations are ones.

126
00:10:36,060 --> 00:10:40,620
That's why we are getting this dark blue color aura into the present.

127
00:10:41,070 --> 00:10:45,590
High purity of zeroes since here.

128
00:10:45,930 --> 00:10:49,970
Two out of two observation are zero.

129
00:10:50,340 --> 00:10:52,290
That's why we are getting this bucket.

130
00:10:52,380 --> 00:10:57,030
An orange color and white represent no purity.

131
00:10:57,780 --> 00:11:03,240
So as you can see, we have almost equal distributions of zero and one in this bucket.

132
00:11:03,300 --> 00:11:13,080
That's why we are getting our color as right now we can also use our parameters while finding classification

133
00:11:13,080 --> 00:11:15,120
tree to control the growth of our tree.

134
00:11:15,750 --> 00:11:19,890
So earlier in this tree, we were using maximum depth as three.

135
00:11:20,010 --> 00:11:24,810
That's why we are getting three level zero level, first level, second level and third level.

136
00:11:25,810 --> 00:11:28,230
Now we are going to use two parameters.

137
00:11:28,470 --> 00:11:33,470
We first want to provide minimum sample size of our leaf as 20.

138
00:11:34,080 --> 00:11:40,590
So we don't want to get this kind of bucket where we have one or two observations in our leaf bucket.

139
00:11:40,650 --> 00:11:45,570
We want the minimum samples in our leaf to be 20.

140
00:11:47,220 --> 00:11:52,890
And we are going to give him maximum depth of four and sort of three.

141
00:11:56,740 --> 00:12:03,760
Again, we are going to find accuracy scored by predicting our white test will lose from this C11 Kree

142
00:12:03,970 --> 00:12:04,810
to murder.

143
00:12:05,740 --> 00:12:07,600
And we are going to roll this model, Lespwa.

144
00:12:13,220 --> 00:12:15,900
So this is our new CCRI here.

145
00:12:16,040 --> 00:12:19,370
We have provided these two conditions.

146
00:12:20,030 --> 00:12:26,280
And as you can see, a earlier over this branch was further dividing and two subbranches.

147
00:12:27,530 --> 00:12:34,850
But now, since we have provided the condition for minimum leave size, we are not getting this bucket.

148
00:12:34,970 --> 00:12:41,500
So we are pruning this branch and we have provided my son that the fourth.

149
00:12:41,650 --> 00:12:45,500
So this branches are further dividing and two different categories.

150
00:12:47,300 --> 00:12:49,060
Let's look at the accuracy score.

151
00:12:51,720 --> 00:12:56,850
So now the accuracy score for our this model is fifty five point eight percent.

152
00:12:56,940 --> 00:12:59,280
Earlier it was fifty four point nine percent.

153
00:12:59,760 --> 00:13:06,690
So they have improved the accuracy score by one percent just by changing the hyper parameters of this

154
00:13:06,690 --> 00:13:07,050
model.

155
00:13:07,290 --> 00:13:13,180
You can try different values as well here and try to get the maximum accuracy score for this model.
