﻿1
00:00:00,133 --> 00:00:01,033
All right, my friends,

2
00:00:01,033 --> 00:00:05,800
I hope you did amazing with that
new exercise, which was to predict

3
00:00:06,000 --> 00:00:10,666
the purchase decision of a new customer in
the data set that was the first customer

4
00:00:10,966 --> 00:00:14,433
who is actually 30 years old and earns

5
00:00:14,433 --> 00:00:19,300
an estimated salary of $87,000, right.

6
00:00:19,300 --> 00:00:21,233
If we have a look at our test set,

7
00:00:21,233 --> 00:00:24,666
you know, the original test
before the scaling, this one,

8
00:00:25,133 --> 00:00:30,500
this is exactly the customer
you had to input in your predict method

9
00:00:30,766 --> 00:00:33,633
in order
to predict the purchased decision.

10
00:00:33,633 --> 00:00:34,366
All right.

11
00:00:34,366 --> 00:00:37,400
And now in this tutorial
we're going to check two things

12
00:00:37,533 --> 00:00:41,466
that first, you've got the right
implementation of the predict method

13
00:00:41,466 --> 00:00:44,533
and mostly
the right input inside the brick method.

14
00:00:44,800 --> 00:00:48,700
And secondly we will also check
if the prediction is correct.

15
00:00:48,700 --> 00:00:51,933
And in order to do this
well we're going to have a look at why

16
00:00:51,933 --> 00:00:57,033
test the purchase decision of that
first customer is exactly this one.

17
00:00:57,233 --> 00:00:58,733
You know because white test contains

18
00:00:58,733 --> 00:01:02,233
all the real results here
or the real purchase decision.

19
00:01:02,533 --> 00:01:06,233
And so we're going to see
if indeed our model was able

20
00:01:06,233 --> 00:01:10,100
to make a correct prediction
by predicting zero

21
00:01:10,733 --> 00:01:15,566
for this first customer of age
30 and estimated salary 87 K.

22
00:01:16,166 --> 00:01:16,600
All right.

23
00:01:16,600 --> 00:01:17,400
Let's do this.

24
00:01:17,400 --> 00:01:20,400
Let's proceed to the solution.

25
00:01:20,633 --> 00:01:22,600
Here it is predicting a new result.

26
00:01:22,600 --> 00:01:24,900
I will leave the training and there we go.

27
00:01:24,900 --> 00:01:26,533
So let's create a new code sale.

28
00:01:26,533 --> 00:01:28,833
And now what was the first step.

29
00:01:28,833 --> 00:01:32,200
Well of course
the first step was to take our classifier

30
00:01:32,233 --> 00:01:35,866
because of course the predict method
as any other method

31
00:01:36,133 --> 00:01:39,133
has to be called from the classifier
object itself.

32
00:01:39,366 --> 00:01:41,400
So we take our classifier object.

33
00:01:41,400 --> 00:01:46,400
And then from this object
we're going to call this predict method.

34
00:01:46,766 --> 00:01:49,033
By the way let me show you this again.

35
00:01:49,033 --> 00:01:50,766
You have all the predict method

36
00:01:50,766 --> 00:01:54,900
which are predict log probability
which will return the log.

37
00:01:54,900 --> 00:01:59,933
You know, the logarithmic function of the
probability that your prediction is one.

38
00:01:59,933 --> 00:02:02,000
You know that
the purchase decision is one.

39
00:02:02,000 --> 00:02:05,833
And you also have to predict proba method,
which returns

40
00:02:05,833 --> 00:02:10,033
of course directly the probability
that the purchase decision is one.

41
00:02:10,033 --> 00:02:10,366
All right.

42
00:02:10,366 --> 00:02:14,533
So depending on whether you want
to have directly the final prediction 0

43
00:02:14,533 --> 00:02:19,500
or 1 or the probability that the dependent
variable is equal to one,

44
00:02:19,500 --> 00:02:23,100
well you have the choice
between predict and predict proba okay.

45
00:02:23,333 --> 00:02:27,000
So here we're going to take predict
because we directly want to get the

46
00:02:27,000 --> 00:02:28,500
prediction whether or not

47
00:02:28,500 --> 00:02:32,966
that first customer of the test
set purchased yes or no the SUV.

48
00:02:33,233 --> 00:02:35,166
So here
we're going to add some parenthesis.

49
00:02:35,166 --> 00:02:38,166
And now now I'm really interested
if you got this right,

50
00:02:38,300 --> 00:02:41,333
what did you put inside the predict method
in order

51
00:02:41,333 --> 00:02:46,200
to predict the purchase decision
of that customer who is 30 years old

52
00:02:46,200 --> 00:02:49,600
and earns an estimated salary of 87,000?

53
00:02:50,400 --> 00:02:53,900
All right, well, 
first of all, let's remind the essential

54
00:02:54,166 --> 00:02:57,733
any single observation inside the predict
method

55
00:02:58,066 --> 00:03:02,400
has to be input
in a double pair of square brackets.

56
00:03:02,400 --> 00:03:03,466
Why is that?

57
00:03:03,466 --> 00:03:06,400
That's
because the predict method expects from

58
00:03:06,400 --> 00:03:09,566
its input a two dimensional array.

59
00:03:09,866 --> 00:03:14,533
And how do we create a two dimensional
array with only one observation?

60
00:03:14,533 --> 00:03:16,266
You know, meaning only one row?

61
00:03:16,266 --> 00:03:21,000
Because what we're about input
is a two dimensional matrix of one

62
00:03:21,000 --> 00:03:24,000
row and two columns,
where the row corresponding

63
00:03:24,100 --> 00:03:29,366
to that single customer and columns
correspond in fact to the feature

64
00:03:29,400 --> 00:03:33,000
is the h in the first column
and salary in the second column.

65
00:03:33,233 --> 00:03:34,200
So there you go.

66
00:03:34,200 --> 00:03:38,200
Now I've told you everything
what you have to input here inside

67
00:03:38,200 --> 00:03:42,000
this second pair of square brackets,
which corresponds to the columns.

68
00:03:42,000 --> 00:03:45,966
Well, you have to input the two values
of these two features,

69
00:03:45,966 --> 00:03:47,633
the age and the salary.

70
00:03:47,633 --> 00:03:51,766
And therefore, since our first customer is
30 years old and earns

71
00:03:51,766 --> 00:03:54,766
an estimated salary of $87,000,

72
00:03:54,866 --> 00:03:57,700
well, the two features here
that we had to input in these.

73
00:03:57,700 --> 00:04:00,700
Therefore, two columns here is first 30

74
00:04:00,900 --> 00:04:04,366
and then $87,000.

75
00:04:04,600 --> 00:04:05,433
All right.

76
00:04:05,433 --> 00:04:08,166
So that's the first thing
you must absolutely do.

77
00:04:08,166 --> 00:04:11,666
You know that
you must absolutely have the right reflex.

78
00:04:11,666 --> 00:04:12,200
Okay.

79
00:04:12,200 --> 00:04:15,800
Input your single observation
within a double

80
00:04:15,800 --> 00:04:18,933
pair of square brackets
to give the expected

81
00:04:18,933 --> 00:04:22,800
format of the two dimensional array
to your prediction method.

82
00:04:23,100 --> 00:04:23,766
All right.

83
00:04:23,766 --> 00:04:26,100
So that was the first thing.
But then not enough.

84
00:04:26,100 --> 00:04:29,100
You had to do something else which is

85
00:04:29,366 --> 00:04:33,400
of course
to scale that single observation.

86
00:04:33,400 --> 00:04:33,766
Right.

87
00:04:33,766 --> 00:04:37,533
Because 30 years old here and $87,000

88
00:04:37,533 --> 00:04:41,666
as the estimated salary
are in the original scale,

89
00:04:41,900 --> 00:04:45,066
you know, before applying feature scaling
standardization.

90
00:04:45,433 --> 00:04:48,133
And since our model was actually trained,

91
00:04:48,133 --> 00:04:53,300
as we can see, on X train and Y train,
which were just previously

92
00:04:53,433 --> 00:04:56,766
feature scaled, you know,
that's the result of feature scaling.

93
00:04:57,200 --> 00:05:00,366
Well, as I told you, the Predict method

94
00:05:00,366 --> 00:05:04,333
can only be applied to observations
where the features

95
00:05:04,600 --> 00:05:08,900
have the exact same scale
as the one that was used for the training.

96
00:05:09,166 --> 00:05:12,500
And therefore here
we need to apply the transform method

97
00:05:12,766 --> 00:05:14,733
in order to give us word break method.

98
00:05:14,733 --> 00:05:18,300
Not only the right format here,
but also the right skill

99
00:05:18,533 --> 00:05:22,866
and that's why we have to transform
this single observation

100
00:05:22,866 --> 00:05:26,166
input in the right format
into that new skill.

101
00:05:26,166 --> 00:05:30,600
And so what we have to do here
is take our SC object.

102
00:05:30,800 --> 00:05:33,966
Remember that was the name of the feature
scaling object,

103
00:05:33,966 --> 00:05:38,133
which we used to apply feature
scaling on both the matrix of features

104
00:05:38,133 --> 00:05:41,900
of the training set extreme and the matrix
of features of the test set X test.

105
00:05:42,233 --> 00:05:45,233
So SC and then remember we call

106
00:05:45,400 --> 00:05:49,200
there
it is just below the transform method.

107
00:05:49,433 --> 00:05:52,466
The transform method
which has to take as input this

108
00:05:52,466 --> 00:05:56,533
whole single prediction
input in a 2D array.

109
00:05:56,600 --> 00:05:58,800
All right. In a second one. And perfect.
