Remember this because, you know, this is your first machine learning model.
So this is the first time you're going to use this fit method.
And then you're going to see you're going to use it all the time.
Whether you're going to do neural networks or anything in artificial intelligence,
the method that we're going to use to train our regression
model is the fit method.
And how do we call such method?
Well, first we have to take the object itself regressor and then add that
and then add the method itself which is fit and add some parentheses.
So as a reminder, the fit method here is a method of the linear regression class.
And I remind also that a class indeed has a couple of not only instructions
but also tools.
And these tools are called the methods.
And these tools complete some actions like training a model
on a certain training set,
or predicting some future results you know, on the test set.
So that's the first method and you'll see that.
Then we'll use another method.
All right.
So basically this fit method will train this regression model
the simple linear regression model on the training set.
And now as you might guess the only thing that's missing here and that we have to
enter in the fit method is of course the training set itself.
However we have to enter it in a certain way because the fit method
expects a certain format of the training set.
And this format is of course, you know, the couple of X train and Y train.
Right?
I remind that X train contains the features, you know,
the independent variables of the training set and Y train contains
the dependent variable vector of the training set as well.
And the fit method here expects exactly the training set in this format with first
the matrix of features x train, and second,
the dependent variable vector x train and y train.
Just like that.
All right.
So now what I suggest is
that we run all the cells because we haven't run any cell so far.
So we're going to do it because indeed when we're going to run the cell
something will happen in the output.
So let's see.
First we have to import the libraries where we import numpy,
matplotlib and pandas.
Then we import into the data set.
Make sure to have it uploaded in Colab.
Then step three.
We were going to split the data set into the training set and the test set.
So there we go.
Now we have xtrain excess weight training white test.
And since we have X train and Y train, well we can now train the simple linear
regression model on the training set by calling this fit method
taken from the regressor object of the linear regression class.
Here we go.
Let's play this cell.
And as I told you, there is something in the output.
That's just to say that indeed
the linear regression model is created and that's the default parameters.
You don't have to worry about them.
But there you go. Congratulations.
You actually built and trained your very first machine learning model.
I'm super excited for you.
I remember how excited I was the first time I did this.
So there you go.
I know the feeling.
But be aware, my friends, that this is the first,
but definitely not the last machine learning model that you're going to build.
We're going to build many others
more complex, of course, and for any types of applications.
So you know, by the end of this course you will know how to do anything
in machine learning.
And that's why we really want to provide code templates for you to be efficient
on how to play with them. Okay.
So congratulations again.
Now we're going to proceed to the next step predicting the test results.
And for this we're going to use a new method.
And so now I would like you to take action I would like you
to try to predict the test results before we do it together.
And I'm going to give you a little hint, even if you can look at it online.
Well, the method that you have to use to predict new observations
is the predict method.
As simple as that.
You know, they chose some simple terms.
So there you go. Try to implement that before me.
That's your little exercise here.
And we will implement this solution together in the next tutorial.