1
00:00:00,240 --> 00:00:07,270
For now, we have been showing you this binary accuracy, false positives up to the AUC.

2
00:00:07,290 --> 00:00:13,300
What if we plot out the coefficient matrix and also the Rosie plot?

3
00:00:13,320 --> 00:00:19,320
So we'll impart cycle, learn and seaborne.

4
00:00:19,600 --> 00:00:29,250
Right here we have scikit learn and from scikit learn dot matrix, we are going to impart coefficient

5
00:00:29,250 --> 00:00:30,210
metrics.

6
00:00:30,510 --> 00:00:37,530
And then for Seaborn, we need to import Seaborn and SAS.

7
00:00:37,530 --> 00:00:38,480
So that's it.

8
00:00:38,490 --> 00:00:48,930
So yeah, we are importing I learn and Seaborn, which we'll both use in plotting out this confusion

9
00:00:48,930 --> 00:00:49,710
matrix.

10
00:00:49,710 --> 00:00:55,140
So let's run this and then we'll visualize our conversion metrics.

11
00:00:55,320 --> 00:01:03,960
So we'll have to get the level that's the true values of one of the outputs, and then we'll also get

12
00:01:03,960 --> 00:01:05,070
the predicted values.

13
00:01:05,070 --> 00:01:09,030
So yeah, we want to get the labels and the predicted values.

14
00:01:09,060 --> 00:01:11,430
Now let's start with the labels.

15
00:01:11,430 --> 00:01:13,650
So yeah, we're going to have labels.

16
00:01:13,770 --> 00:01:17,850
We have this list, there we go.

17
00:01:17,850 --> 00:01:31,860
And then for X, Y, or let's say for, for x, Y in the test data set, we're going to take this as

18
00:01:31,890 --> 00:01:33,570
non py iterator.

19
00:01:33,570 --> 00:01:44,280
So for x, Y and this we have the x and the Y, we have that and then we append every output to this

20
00:01:44,280 --> 00:01:44,790
labels.

21
00:01:44,790 --> 00:01:50,070
So here we have labels that append y and we run that.

22
00:01:50,160 --> 00:01:51,150
So that's fine.

23
00:01:51,150 --> 00:01:53,430
We could now print out labels.

24
00:01:53,430 --> 00:01:54,630
What do we get?

25
00:01:55,140 --> 00:01:56,100
There we go.

26
00:01:56,250 --> 00:01:57,720
You see, we have this labels.

27
00:01:57,720 --> 00:02:07,440
Now let's convert it into a simpler form where we just have only this values in here and not this arrays

28
00:02:07,440 --> 00:02:08,760
which we have here.

29
00:02:08,760 --> 00:02:16,170
So in order to get that, we have labels will be equal labels or rather will be equal an array.

30
00:02:16,320 --> 00:02:18,690
And in here we're going to create this list.

31
00:02:18,690 --> 00:02:25,110
So in this list here, for every element of this labels list.

32
00:02:25,110 --> 00:02:36,470
So for here, for I in labels, we are going to do I the zero.

33
00:02:38,230 --> 00:02:38,860
Index.

34
00:02:38,860 --> 00:02:42,220
So we're going to take always this element right here.

35
00:02:42,370 --> 00:02:45,460
So that said, we have that and now we have levels.

36
00:02:45,460 --> 00:02:48,760
Let's print out a levels after doing this transformation.

37
00:02:49,390 --> 00:02:50,260
There we go.

38
00:02:50,290 --> 00:02:51,750
Here is our levels now.

39
00:02:51,760 --> 00:02:54,670
So we have that fine could take that off.

40
00:02:56,110 --> 00:03:01,810
We have this error actually because we tried we've converted this levels already and then we're trying

41
00:03:01,810 --> 00:03:02,680
to re convert them.

42
00:03:02,680 --> 00:03:06,250
So let's command this right here.

43
00:03:06,250 --> 00:03:09,610
We command that and run this and we have all levels.

44
00:03:09,700 --> 00:03:11,560
OC Now we have those levels.

45
00:03:11,560 --> 00:03:15,490
We could move ahead and get the predicted values.

46
00:03:15,490 --> 00:03:22,350
So to get this predicted values, we have our low net model Loonette learned model.

47
00:03:22,360 --> 00:03:28,960
There we go dot predict what are we going to pass in this predict method is our input.

48
00:03:28,960 --> 00:03:35,800
So we have the input and then right here we add this input list and then we do same as we did with the

49
00:03:35,800 --> 00:03:36,280
labels.

50
00:03:36,280 --> 00:03:37,510
So we have input.

51
00:03:37,510 --> 00:03:41,300
Then append X, which is this input here.

52
00:03:41,320 --> 00:03:45,160
Now we run this and then let's add a cell.

53
00:03:45,160 --> 00:03:49,420
So we add this code cell and then we're going to pre process our input.

54
00:03:49,420 --> 00:03:54,950
So from this we're just going to print out the input to see what it gives us, what kind of shape we

55
00:03:54,950 --> 00:03:56,140
are having right here.

56
00:03:56,290 --> 00:03:58,120
Let's put non power array.

57
00:03:58,870 --> 00:04:01,120
Wow, that's loading shape.

58
00:04:01,870 --> 00:04:02,830
Then we run this.

59
00:04:02,830 --> 00:04:07,930
All the cell right here is what we get as shape.

60
00:04:07,930 --> 00:04:12,040
So we have to take this off, this one off here.

61
00:04:12,040 --> 00:04:18,700
And to do that you see we would have the input will select this first index.

62
00:04:18,700 --> 00:04:23,080
So we take that and then for this next we take only one.

63
00:04:23,080 --> 00:04:27,280
So we're going to chop this off and then we have the rest.

64
00:04:27,280 --> 00:04:28,250
So that's it.

65
00:04:28,270 --> 00:04:35,920
Now we run this again and we should have put a shape here, so we run that again.

66
00:04:37,660 --> 00:04:38,860
And there we go.

67
00:04:38,860 --> 00:04:40,570
So this is what we expect.

68
00:04:40,600 --> 00:04:47,560
Now we've gotten the labels and then we are now ready to get the predictions.

69
00:04:48,070 --> 00:04:53,260
So here we have this input or take this and then we pass it in.

70
00:04:53,260 --> 00:04:56,200
Here we pass our input and we get our predictions.

71
00:04:56,200 --> 00:05:02,590
Let's print out the predicted here or yeah, let's print out a predicted and see what we get.

72
00:05:02,830 --> 00:05:08,590
So what we get right here, we could print out a shape to better understand what this is.

73
00:05:08,920 --> 00:05:11,500
And as you could see, we have this.

74
00:05:11,500 --> 00:05:15,730
So how do we take this off or how do we make it look like the labels?

75
00:05:16,600 --> 00:05:19,590
We could simply take this off.

76
00:05:19,600 --> 00:05:20,860
So we have.

77
00:05:20,860 --> 00:05:25,150
We select the first, and then for this one, we take it off.

78
00:05:25,150 --> 00:05:26,770
So we run that again.

79
00:05:27,520 --> 00:05:28,690
And there we go.

80
00:05:28,690 --> 00:05:36,670
So now we could do this, take off the shape, and then it should look like the labels we've had here.

81
00:05:37,630 --> 00:05:38,370
And that's it.

82
00:05:38,380 --> 00:05:40,030
So now we've gotten this.

83
00:05:40,990 --> 00:05:49,220
Our next step is to use the confusion matrix from circle and matrix and produce our conversion matrix.

84
00:05:49,240 --> 00:05:55,960
Now let's comment this sections first so you will pass in the labels with pass in the predicted and

85
00:05:55,960 --> 00:05:57,630
then we'll specifying this threshold.

86
00:05:57,640 --> 00:06:03,880
So what we're seeing here is all the values greater than the threshold considered uninfected and all

87
00:06:03,880 --> 00:06:05,350
values less than or equal.

88
00:06:05,350 --> 00:06:10,240
The threshold is going to be considered as containing the parasite.

89
00:06:10,330 --> 00:06:13,360
And then we're going to have this in this conversion matrix here.

90
00:06:13,360 --> 00:06:14,470
So we run that.

91
00:06:14,680 --> 00:06:20,920
And then as you could see, we have our coefficient matrix, which shows us the number of true positives,

92
00:06:20,920 --> 00:06:24,930
true negatives, false positives and false negatives.

93
00:06:24,940 --> 00:06:31,720
Getting back to our model evaluation, we'll see exactly which of those values are the true positives,

94
00:06:31,720 --> 00:06:34,330
false positives, true negatives or false negatives.

95
00:06:34,330 --> 00:06:36,580
So let's just copy this out.

96
00:06:36,610 --> 00:06:42,750
Your if we take this up and we shall see that below.

97
00:06:42,760 --> 00:06:49,810
So here we have this confusion matrix, which we've just seen here is it right here, confusion matrix

98
00:06:49,810 --> 00:06:50,500
right here.

99
00:06:51,190 --> 00:06:52,990
And then let's paste this out here.

100
00:06:52,990 --> 00:07:00,940
So we have the number of true positives this one matches and then number of true negatives.

101
00:07:00,940 --> 00:07:02,560
1298.

102
00:07:02,590 --> 00:07:03,700
Yeah, this is closer.

103
00:07:03,700 --> 00:07:10,360
So what cyclone gives us is quite similar to what we had with TensorFlow, but they're not exactly the

104
00:07:10,360 --> 00:07:10,870
same.

105
00:07:10,870 --> 00:07:13,810
So this tells us that this is a number of true negatives.

106
00:07:13,810 --> 00:07:18,220
This is the number of no, this is the number of true negatives right here.

107
00:07:18,220 --> 00:07:19,810
So here we have two negatives.

108
00:07:19,810 --> 00:07:22,060
Here we have true positives.

109
00:07:22,150 --> 00:07:27,760
Then here we have false positives and then here we have false negatives.

110
00:07:28,190 --> 00:07:36,880
We'll then see how modifying this threshold will either reduce the false negatives or reduce the false

111
00:07:36,880 --> 00:07:37,660
positives.

112
00:07:39,340 --> 00:07:42,790
So let's have, say, 0.25 right here.

113
00:07:42,790 --> 00:07:45,790
We run that again and there we go.

114
00:07:46,330 --> 00:07:47,320
Let's print this.

115
00:07:47,320 --> 00:07:51,640
So we see that we now have a number of false negatives reduced.

116
00:07:51,640 --> 00:07:57,520
When we reduce this threshold, we now go back and then take this to 0.75.

117
00:07:57,520 --> 00:07:58,690
We run that again.

118
00:07:59,170 --> 00:08:00,940
You see that this is now reduced.

119
00:08:00,940 --> 00:08:07,120
So here we have a reduced or an increased number of false negatives and a reduced number of false positives

120
00:08:07,120 --> 00:08:10,150
when this threshold is increased to 0.75.

121
00:08:10,870 --> 00:08:12,100
So that's it.

122
00:08:12,100 --> 00:08:14,410
Let's now print out.

123
00:08:14,410 --> 00:08:14,830
All right.

124
00:08:14,860 --> 00:08:21,570
Let's now plot out this more elegantly looking figure with the Seaborn Library.

125
00:08:21,580 --> 00:08:22,540
So here we go.

126
00:08:22,540 --> 00:08:24,820
We run that and that's it.

127
00:08:24,820 --> 00:08:31,780
So here we have our same conversion matrix, but more elegantly plotted.

128
00:08:31,990 --> 00:08:37,270
Let's take it back to 0.5 here and have that.

129
00:08:37,270 --> 00:08:38,590
Okay, so that's it.

130
00:08:39,580 --> 00:08:45,610
Now, you notice that when we're trying to say reduce more false negatives or number of false positives,

131
00:08:45,610 --> 00:08:49,390
what we're doing is we are just picking up some values here.

132
00:08:49,390 --> 00:08:55,150
Like we could pick up 0.2 and then we see this effect and we could do the same for 0.25.

133
00:08:55,150 --> 00:08:58,960
You see how this takes us to 58 and there's 230.

134
00:08:58,960 --> 00:09:04,240
We could continue doing this until we get our best results.

135
00:09:04,240 --> 00:09:09,680
But then this isn't very efficient since we just trying out different values.

136
00:09:09,700 --> 00:09:16,090
Now, the way we could do this more efficiently is by working with our C plots where we'll be able to

137
00:09:16,120 --> 00:09:20,050
choose a threshold in a more efficient manner using the plots.

138
00:09:20,050 --> 00:09:25,960
And so we'll be able to reduce the number of false negatives or the number of false positives without

139
00:09:25,960 --> 00:09:29,950
having to try out all this trash values manually.
