Hello my friends.
I hope you're feeling fantastic.
Now, after this,
first data preprocessing phase that we tackled in a flashlight together.
Now we're ready for the exciting step, which is to train the multiple linear
regression model
on the training set that we now collected thanks to the previous step.
But first, before we do this, I would like to answer two important questions.
The first question is do we have to avoid, you know,
to do something to avoid the dummy variable trap?
And the answer is no, because indeed the multiple linear
regression class that we're about to import
and which will build the multiple linear regression model itself
and actually also train it, because remember that a class actually
can complete several actions, including building it and training it.
And well, this class will automatically avoid this trap.
Which means that indeed, you know one of the three first columns here.
Because remember, Kirill explained that one is redundant.
Well, will automatically be outcast, so you have nothing to worry about
regarding the dummy variable trap.
You don't have to remove one of the columns here.
And that's the beauty of classes.
You know, these are advanced implementations that allow you to build
a model and machine learning model in just a few lines of code,
and this will take care of the dummy variable trap for you.
Now second question do we have to work on the features
to select the best ones with, you know, the techniques
that Kirill introduced to you, like for example, backward elimination.
Do we have to deploy the backward elimination technique
in order to select the features that have the highest p values?
And and there are the most artistically significant.
And the answer is once again no.
Why is that?
Well, for the exact same reason as the dummy variable trap,
the class that we're about to call to build our multiple linear regression
model will automatically identify the best features.
You know, the features
that have the highest p values, or that are the most artistically significant
to figure out how to predict the dependent variable.
You know, the profit with the highest accuracy.
So once again, you don't have to worry about this.
The class of scikit learn.
You know, this amazing data science library
will take care of everything for you. Okay.
So I'm glad to answer these two questions.
You know, the purpose of building machine learning models today is to be efficient
because in your career, you know, I can't tell you how many times I had
to test several machine learning models on my data sets and select the best one.
Well, you know, if I had to deploy the backward elimination
technique on my data set, well, I would have lost a lot of time.
And here we have a class that takes care of everything.
You just have to deploy
your class on your data set, and then you will get an accuracy.
And you will compare that accuracy with the accuracies of other models.
And you know, that process is called model selection.
That's what we actually cover in the portion of this course.
So really I want you to be efficient with,
you know, your implementations and your machine learning toolkit
so that you can optimize your model selection process.
All right.
So now that we said this
well let's build together the multiple linear regression model.
And now actually I have some good news
because you know we're still doing linear regression.
And in the previous section we actually did simple linear regression
with which we did for had one feature in our data set.
And now we're doing multiple linear regression, which is exactly the same
as simple linear regression except that we have several features.
So the good news is actually that the class
that we're about to use to build and train this multiple linear regression model
is actually the exact same class as for the simple linear regression model.
It will just recognize that there are several features,
and therefore that we are doing multiple linear regression,
but the rest will be exactly the same.
It will be trained to understand the correlations between all your features.
Actually I can open it here.
All your features and the profit which is your dependent variable.
And then it will take care of the dummy variable.
And it will also take care of selecting the best features
that are the most statistically significant.
So that's the good news.
But still I just want to re-implement this again from scratch
to make sure it is best integrated in your head.
All right.
So let's close this and let's implement our multiple linear regression model.
I actually tried to do it faster than me.
Try to do it before me.
You know you can press pause on this video and do it.
And me, I'm going to do it pretty efficiently.
So remember we have to start from the sklearn,
the scikit learn library from which we're going to get access
to this specific module which is linear model.
There we go. Google Colab guesses it perfectly.
And from this module we're going to import it.
Well the linear regression
class Google Collab guess is again perfectly all right.
So that's the exact
same class as in the previous section on simple linear regression.
And there you go.
We're going to do just exactly the same.
You know, this is exactly the same code as what we did in the previous section,
because now we're going to create a new variable which will be our multiple linear
regression model,
which will be created as an object of this linear regression class.
So let's introduce this new variable regressor equals.
Well since this will be an object of the linear regression class, I'm
just copying this class and pasting it here and adding some parenthesis.
All right.
So that regressor is created as an instance of this linear regression class.
Now the question is do we have to enter any parameters here.
Well just like simple linear regression the answer is no.
We are just going to keep
the default values of the parameters inside this linear regression class.
I will explain in a whole section parameter tuning.
You know when you can improve your model.
But for linear regression it's pretty simple.
So usually we don't have anything to input here.