Perfect.
And now, final step.
You know what you have to do, right?
We have to take first our classifier and then.
Well, now what we want to do is to train our classifier on the training set.
Because remember that this line of code only builds
the logistic regression model but doesn't train it yet.
And this next line of code is indeed the final step
where we train our classifier on the training set.
And remember to do this, we have to call the fit method,
which takes as input two entities, you know, two sets of data.
The first one is the matrix of features of the training set,
and the second one is the dependent variable vector of the training set, where
of course, all the purchase decisions of the dependent variable vector
correspond to the same customers of the matrix of features.
All right.
So what we had to input here was simply X
train for the matrix of features of the training set.
And then y train for
the dependent variable vector of the same training set.
And there you go my friends. Congratulations.
If you obtained this and also congratulations if you tried.
Because indeed that's how you build the logistic regression model.
So there you go.
That's one extra machinery model in your toolkit.
And you're going to have many more.
And don't worry I will train you on how to select
the best one for any data set.
Okay. Great. So let's run this cell.
This will indeed build and train the logistic regression
model on your training set composed of X and Y train.
And here, by the way, you see all the parameters
of the logistic regression model which you can tune.
The most famous one is C which is inverse of the regularization
strength, meaning that the smaller is c, the stronger will be the regularization,
and therefore the more it will protect you from overfitting.
Right here we'll just keep the default value of one.
And there you go.
We're ready to move on to the next step predicting a new result.
And so now new exercise for you because we already did it with regression
I taught you before how to, you know, take your regressor and then call
the predict method to predict the result of a single observation.
And so here the exercise that I would like you to do
is to predict the purchased decision of a single result,
you know, the purchase decision of a single customer.
And I will tell you which one I would like you to predict
the purchased decision of the first customer in the test set.
Who you will see is 30 years old and earns
an estimated salary of $87,000.
So I would like you to take these two inputs.
You know, these two features with these values, 30 years old
and $87,000 as the estimated salary.
And I would like you to predict whether this customer has bought yes or no.
The SUV, you have the answer and y test.
You know, you take the first result of Y test,
and thus you'll be able to compare your prediction to the real result
to figure out whether your prediction was correct.
And so there you go. Please do the exercise.
Please try to do this on your own first before we do it together
in the next tutorial, please predict the purchase decision
of that first customer of the test set and we will
of course implement the solution in the next tutorial.
Until then, enjoy machine learning.