All right.
And now the last step that you had to do was to figure out what
to replace here in this feature scaling implementation.
Well, here that's super easy.
We simply want to, you know, feature scale, all the features.
We want to scale all the features.
We want to scale age and salary.
And of course we don't have to scale the dependent variable purchased
because its values are zero and one and therefore are already
in the range of values we want. So all good with this.
So basically we're only going to scale these two features age
and estimated salary.
And therefore here what we just have to do, you know as replacements
was just to remove that selection of the indexes here.
Here we selected old indexes starting from three.
But this time we don't have to do anything.
We can just scale the whole matrix of features.
So I'm just removing here the index selections.
And there you go.
We'll be ready to feature scale both our training set and our tests.
It and I remind that this is absolutely compulsory to do this.
After splitting the data set into the training set and test it
in order to avoid information leakage from the test set.
All right.
So there you go, my friends.
That was what you needed to do for data preprocessing.
Congratulations.
If you've got the same thing don't worry about that test size.
This is just for the form. But there you go.
This was simply what you had to do.
All right.
So now we're going to do a few prints
to actually see the before and after feature scaling.
So what I'm going to do is right after this
code cell splitting the data set into the training set and test set.
I'm going to make four prints just to show you if you don't need to
look at that will feel free not to include these new code cells.
But what I want to do is print first X train.
Then I would like to print y train.
So here y train.
Then next one I would like to print x test.
And finally I would like to print
well y tests okay.
So that's an after feature scaling.
However we will just, you know print two cells
because we actually don't apply feature scaling to Y.
And therefore we'll just print first.
Well x train again.
And second X test. Right.
Because these will be the only sets of data that will be changed.
All right. Perfect.
So now let's execute everything we have the data set.
All good.
So let's do this starting by importing the libraries.
Good.
Now importing the data set crate.
Now splitting the data set into the training set and test set.
There we go.
All right.
Now let's print X train and see what it looks like.
All right. So let's scroll down a bit.
All right.
That's Xtrain was first the current age and the age feature.
And second column, the estimated salary, the estimated salary feature.
All right.
And of course we have 300 observations in this training set.
You don't have to count them.
But there you go. We have many of them.
All right.
So now let's print Y train is just to have a look at what we create.
You know this is not compulsory.
So that's why train with all the purchased decisions on the previous SUV's.
Zero means that the customer did not buy any SUV.
And one means yes, the customer bought a previous SUV and now x test.
Scroll down a bit right? X does so same.
It contains 100 observations, corresponds to 100 customers,
and for each of them their age and the estimated salary.
And you know, since X test is actually supposed to be
some new data in production, well, we're actually going to suppose that
X test is actually the set of customers who purchased yes or no, the new SUV.
No. We're going to pretend that X test is actually some data
when we deploy our model in production, so that we can evaluate it
on the new observations we need on the new customers buying.
Yes or no, that new SUV.
All right.
It's more fun if we imagine access this way
because it is indeed supposed to be some new observations and now y test.
Let's see.
All right.
And white test contains of course
old the purchased decisions of the customers in this test set.
Meaning whether or not they bought the new SUV.
All right.
Perfect. So now let's apply feature scaling.
And let's see how X train and X tests are transformed.
All right.
So let's do this. Let's play.
And now let's print X train.
All right.
So now we have some scaled values between well you know
minus two and plus three.
You know this one is 2.06 -1.7.
Anyway should be somewhere between minus three and plus three okay.
But now we can clearly see that we have both the two features in the same range.
The transformed age and the transformed estimated salary
are now indeed in the same range.
And that's exactly what we're supposed to get with features killing.
All right.
So now let's scroll down to print X test.
And this same we get the two features H and salary taking values in the same range
between somewhere around minus three and plus three.
So this will improve the training performance of the genetic regression
model.
Well you know for the training set of course only for the training set.
But then when we will deploy our model to predict
whether the customers of the test set.
But yes or no, the new SUV, well,
we will have indeed to apply the predict method on these scaled values.
Otherwise predictions will be nonsense, right?
The predict method has to be called on a set of features
with the same scale as the one that was applied during the training.
Okay, perfect.
So now we can move on to the next exciting step
where we build and train our logistic regression model on the training set.