﻿1
00:00:00,600 --> 00:00:01,800
So I know

2
00:00:01,800 --> 00:00:04,800
it's supposed to be a template
that work for every classifier,

3
00:00:05,133 --> 00:00:09,166
but the k in and classifier
will be the only classifier

4
00:00:09,166 --> 00:00:12,166
we will need to change
something in the template.

5
00:00:12,300 --> 00:00:15,233
And that's because of this structure
we changed here.

6
00:00:15,233 --> 00:00:18,900
You know, for all the classifiers
we had this first section

7
00:00:18,900 --> 00:00:22,266
where we create our classifier with the,
you know, classifier equals

8
00:00:22,266 --> 00:00:24,600
and then we create our classifier
with the function.

9
00:00:24,600 --> 00:00:27,766
And then in another section
we create a widespread

10
00:00:27,966 --> 00:00:31,533
using the classifier
we built in this section above.

11
00:00:32,000 --> 00:00:34,200
But here,
since we did both at the same time,

12
00:00:34,200 --> 00:00:37,233
we just need to change a little thing
here in the template.

13
00:00:37,700 --> 00:00:39,233
Can you guess what it is?

14
00:00:39,233 --> 00:00:42,466
Okay, so it's actually in this line
because as you can see here

15
00:00:42,633 --> 00:00:46,866
we are using the predict function
on our classifier.

16
00:00:47,066 --> 00:00:50,733
But here, since we didn't
create a classifier separately

17
00:00:50,933 --> 00:00:53,533
from the vector
of prediction of white bread,

18
00:00:53,533 --> 00:00:57,433
well that means that this predict
classifier doesn't mean anything here.

19
00:00:57,433 --> 00:00:59,466
So actually it's really simple.

20
00:00:59,466 --> 00:01:02,866
What we need to do is to replace this
predict classifier.

21
00:01:02,900 --> 00:01:06,700
New data equals
group set by this code here.

22
00:01:06,700 --> 00:01:09,766
Because this is actually like the predict
function on the.

23
00:01:09,766 --> 00:01:12,700
It's creating the classifier and
making the predictions at the same time.

24
00:01:12,700 --> 00:01:14,833
So there is not a predict function here.

25
00:01:14,833 --> 00:01:16,133
So it's very simple.

26
00:01:16,133 --> 00:01:18,300
Where we only need to do is to take this

27
00:01:19,366 --> 00:01:20,500
command C.

28
00:01:20,500 --> 00:01:22,800
And here you know, since
it's all the predictions

29
00:01:22,800 --> 00:01:26,533
of the pixel points in the grid,
we will need to change this.

30
00:01:26,533 --> 00:01:28,733
New data equals test set.

31
00:01:28,733 --> 00:01:31,900
So this test equals test set by grid set.

32
00:01:32,100 --> 00:01:33,900
So basically it will be very simple.

33
00:01:33,900 --> 00:01:38,366
We will remove this predict function here
and paste that.

34
00:01:39,133 --> 00:01:42,500
And here
we're just going to replace test set by

35
00:01:43,600 --> 00:01:45,600
grid set.

36
00:01:45,600 --> 00:01:49,600
Because we want to predict
if those imaginary pixel points

37
00:01:49,633 --> 00:01:54,566
that we picture as imaginary users
of the social network will buy yes or no,

38
00:01:54,566 --> 00:01:57,600
the SUV according to their coordinates

39
00:01:57,600 --> 00:02:00,600
in the graph that is their age
and their estimated salary.

40
00:02:00,733 --> 00:02:05,200
And then once the prediction is done,
it will be colorized in the proper color

41
00:02:05,600 --> 00:02:06,166
green.

42
00:02:06,166 --> 00:02:09,433
If this imaginary user
pixel point is predicted to buy

43
00:02:09,433 --> 00:02:12,466
the SUV, and red
if it's predicted not to buy the SUV.

44
00:02:12,866 --> 00:02:14,400
And that's it, that's all we need.

45
00:02:14,400 --> 00:02:17,533
So we are going to select this as well

46
00:02:19,200 --> 00:02:22,900
and paste
it here to do the same for the test set.

47
00:02:22,900 --> 00:02:25,833
Of course, it's the same.

48
00:02:25,833 --> 00:02:26,900
And here we go.

49
00:02:26,900 --> 00:02:29,900
And then we are all good
to plot the results.

50
00:02:30,033 --> 00:02:30,800
So let's do this.

51
00:02:30,800 --> 00:02:34,633
We're going to select this
and let's see what we obtain.

52
00:02:35,100 --> 00:02:35,866
Command and control.

53
00:02:35,866 --> 00:02:39,266
Plus enter to execute the graph.

54
00:02:39,266 --> 00:02:40,033
The plot is coming.

55
00:02:40,033 --> 00:02:43,800
You're going to see
how the cannon manages to classify

56
00:02:43,800 --> 00:02:45,266
the two classes of users.

57
00:02:45,266 --> 00:02:48,166
Those who didn't buy the SUV
and those who bought the SUV.

58
00:02:48,166 --> 00:02:49,100
And here we go.

59
00:02:49,100 --> 00:02:49,900
That's the graph.

60
00:02:49,900 --> 00:02:52,500
That's the prediction boundary here.

61
00:02:52,500 --> 00:02:54,666
So you can see
there are a lot of irregularities,

62
00:02:54,666 --> 00:02:58,000
but that's because of the way
the cannon model works,

63
00:02:58,000 --> 00:03:01,266
because it's taking each time
the five nearest neighbors.

64
00:03:01,833 --> 00:03:04,233
That's all the prediction boundary.

65
00:03:04,233 --> 00:03:06,233
These are our two prediction regions.

66
00:03:06,233 --> 00:03:07,800
The red one and the green one.

67
00:03:07,800 --> 00:03:08,700
All these points here

68
00:03:08,700 --> 00:03:12,066
are the real observation
points are real users of the data set.

69
00:03:12,066 --> 00:03:13,200
And they're real results.

70
00:03:13,200 --> 00:03:14,800
Whether they bought yes, the SUV,

71
00:03:14,800 --> 00:03:18,066
if it's green and no,
they didn't buy the SUV to train.

72
00:03:18,933 --> 00:03:23,166
So we can see that most of our predictions
are correct because all the red

73
00:03:23,166 --> 00:03:26,900
points are in the red region and most of
the green points are in the green region.

74
00:03:27,300 --> 00:03:32,966
We also see that the cannon classifier
makes a much better job at classifying

75
00:03:32,966 --> 00:03:35,966
those users here
that their logistic regression couldn't

76
00:03:35,966 --> 00:03:38,600
classify correctly
because it was a straight line,

77
00:03:38,600 --> 00:03:42,866
and as some green points
were falling on the red region.

78
00:03:43,266 --> 00:03:46,000
So here it's a much better job.

79
00:03:46,000 --> 00:03:49,666
And all those users with the knowledge
above the average and an estimated salary

80
00:03:49,666 --> 00:03:53,033
below the average are now
well classified in the green region.

81
00:03:53,466 --> 00:03:55,000
So very good, very good.

82
00:03:55,000 --> 00:03:59,300
But let's not scream victory
until we find out about the results

83
00:03:59,300 --> 00:03:59,900
on the test set.

84
00:03:59,900 --> 00:04:01,766
Because since this is the training set

85
00:04:01,766 --> 00:04:04,033
and the canine
classifier was built on the training set,

86
00:04:04,033 --> 00:04:06,000
we might get different results
on the test set.

87
00:04:06,000 --> 00:04:08,366
So let's see I'm going to select this.

88
00:04:08,366 --> 00:04:11,933
The test set results already execute.

89
00:04:12,700 --> 00:04:14,033
And these are great results.

90
00:04:14,033 --> 00:04:16,033
Most of the red points are in the red
region.

91
00:04:16,033 --> 00:04:18,566
Most of the green points
are in the green region.

92
00:04:18,566 --> 00:04:21,300
And of course we had a few incorrect
predictions

93
00:04:21,300 --> 00:04:24,333
like these two guys here
or these two guys here.

94
00:04:24,866 --> 00:04:26,733
But here it looks very good.

95
00:04:26,733 --> 00:04:30,166
And we have made nice prediction regions.

96
00:04:30,566 --> 00:04:33,066
Okay, so that's it for this tutorial.

97
00:04:33,066 --> 00:04:36,600
I hope you enjoyed discovering
this new type of classifier.

98
00:04:36,600 --> 00:04:40,833
We are going to discover new kinds
of classifiers in the next sections.

99
00:04:41,066 --> 00:04:44,200
I can't wait to show you this
and until then, enjoy machine learning.
