And now final step.
You know, with this line of code, we actually built the multiple linear
regression model. So we have the model already on the right.
Now it is dumb.
You know, it is not trained yet on the data set.
So now we're going to make it smart by training.
It's indeed on our training set composed of remember X train and Y train.
So there we go.
Let's take our regressor object
from which we're going to call the fit
method which takes us input.
Right. Exactly the same as before.
First, the matrix of features x train.
And second the dependent variable vector y train of the training set.
Of course.
All right. And that's it.
This line of code will build our multiple linear regression model.
And this line of code will train it on our training set.
All right. Perfect.
So now let's just execute the cell.
So let me check the cells that we didn't execute before.
So we executed everything up to here.
So we still have to execute this cell
you know to split indeed the data set into the training set and test it.
And now we have the training set.
And therefore we can proceed to this next step to train
the multiple linear regression model on the training set.
So here we go. Let's do it clicking play.
And there we go.
We now have a fully trained linear regression model on this data set.
So now we have a model that was trained to understand the correlations
between different types of spins by 50 strips and their profit,
so that now investors can deploy this model on new startups
in order to predict what profit they will generate based on these informations.
All right. Perfect. So congratulations.
Now let's recap. You know three things.
Thanks to this amazing linear regression class.
You don't have to worry about the dummy variable trap.
You don't either have to worry about selecting the best features
meaning the features
with the highest p value or the most statistically significant.
The linear regression class will take care of that as well.
And also, you know how to build and train a multiple linear regression model
on a data set, which you also know how to preprocess like a pro.
All right.
So we're now
going to move on to the last step which will be to predict the test results.
Because remember that so far our model was trained on the training set.
And therefore we still need to check its performance on new observations
which are contained in the test set.
However, here we have to understand something important.
You know, compared to what we did
in the previous section on simple linear regression.
This time we actually have several features, right?
We actually have four features instead of one like before.
And therefore we can not actually plot a graph
like we did in simple linear regression where, you know,
we have the features in the x axis and the dependent variable in the y axis.
Because simply there are four features
we would need actually a five dimensional graph,
which is not possible to visualize as humans.
So what we're going to do instead, you know, instead of visualizing
the test results on a plot, well,
we will actually display two vectors.
The first one is the vectors of the real profits in the test set.
And remember that the test set actually counts for 20% of the whole data set.
And therefore here there are, you know, actually
50 observations corresponding to the 50 strips.
Well, 20% of 50 will be ten observations in the test set.
So we will actually have ten samples in the test set.
And we will display two vectors.
First the vector of the ten real profits from the test set.
You know, the ten ground truth and the second vector of the ten predicted
profit of the same test set, so that we can compare for each strip
of the test set if our predicted profit is close to the real profit.
And that's how we will, you know, evaluate our model.
And then later on in this part, you will actually learn
about some evaluation techniques to measure better
the performance of your regression models with some relevant metrics.
But so far, this is how we will do it.
We will clearly see if you know our model performs
well on your observations, you know, on the test set,
because we will clearly see if the predictions are close to the real results.
Okay.
So you can try to do it yourself at least the first step,
which is to get the vector of predicted profit.
But then in order to display the two vectors, you know, next to each other,
well, we'll have to use some certain tricks which are not necessarily obvious.
So we'll do that together. All right.
So as soon as you're ready let's proceed to the next tutorial.
And until then enjoy machine learning.