All right.
So for us we don't have a training set of tested here.
So I'm going to remove this line of code.
I'm going to you know remove that as well.
All the index selections and here as well.
And I'm just keeping x.
And then let's see what we have to do.
All right.
So first that's already more clean.
Now with what we have here.
You know these three lines of code, we are indeed applying feature
scaling to the matrix of features X, which is one of the things we have to do.
Indeed. That's good.
However, as we've just explained, we also have to scale
the dependent variable vector, the salaries, and of course,
and that's the important thing you had to understand and figure out.
We're not going to use the same standard scaler object
on both the matrix of features X and the dependent variable vector y.
Why is that?
That's because, you know, when you fit your object and C
on your data, well, it is going to compute
the mean and the standard deviation of that same variable.
And therefore since of course we don't have the same mean and same
standard deviation for our levels here and our salaries, well, obviously
we have to create two standard scaler object, one that will be fitted to X
in order to compute the mean and standard deviation of the position levels,
and one that will be fitted to Y to indeed
compute the mean and the standard deviation of the salaries.
All right.
So that was the only important thing to understand.
And therefore here I'm actually going to call this subject c x
in order to say that it's the scalar of the matrix of features x.
And here's x as well.
And now I'm going to create a new standard scalar object,
the one that will be used on our dependent variable vector y.
And therefore here I'm replacing x by we're going to call it's c
y so that it's perfectly clear that this is a scalar of x.
And this is a scalar of y.
And now we're going to copy this paste that right below.
And here we'll just have three little replacements to do
which are first replacing x here by y.
Then x here by c y and x here by y.
So that now we are ready to scale both
our matrix of features x and our dependent variable vector y.
Let's check it out. Let's run this cell.
And now we're going to add two new code cells
to print the new x and the new y and see what they have become.
All right so two new code cells.
And let's start here with a print of X.
Good.
And then a print of Y.
And now let's run these two cells here starting with print x.
And indeed well we have some perfectly scaled values
of the position levels going from -1.5.
And that corresponds of course to position level number
one and 1.56 which corresponds to position level number ten.
All right.
So now let's print y.
And this will be interesting.
Here the values will go from minus 0.7 which corresponds
of course to the salary of 45,000 for year and 2.64
which corresponds to the $1 million salary.
And as you can see here, this time
the values are in the range from minus one to plus three.
That's why in the data preprocessing part I told you that usually standardization
transform your values between minus three and plus three.