All right.
Great.
So this will apply feature scaling to our two comes into training set.
And now I hope you know what the next step is going to be.
And you won't fall into the trap.
Now we have to also transform
our matrix of features to the test set, meaning x.
Test this matrix of features, but
since this data is like new data, which we get, you know,
later on in production,
well, for this data we will only apply the transform method
because indeed the features of the test set need to be scaled
by the same scaler that was used on the training set.
We can not get a new scaler.
You know, if we apply the fit transfer
method here on X test, we would get a new scaler.
And that would absolutely not make sense because X test will actually be the input
of the predict function that will return the predictions,
you know, after the machine learning model is trained.
And since this machine learning model will be trained
with a particular scaler, you know, the scaler applied on the training set.
Well, in order to make predictions that will be congruent with the way
the model was trained.
Well, we need to apply the same scaler that was used on the training set
onto the test set, so that we can get indeed the same transformation
and therefore Indian.
Some relevant predictions with the predict method applied to X test.
So here it's clearly the transform method that must only be applied.
And therefore what we're going to do to make it
efficient is well we're going to copy this line of code.
And just below we're going to paste it.
We're going to replace of course Xtrain by X test.
And then here as well X trained by X test.
And then just call of course the transform method
from that same scaler that was applied on the training set.
Because indeed this is part of the training. Right.
Even if we haven't started the training.
Well, this operation that we apply here on our training set
is, you know, the preparation of the training.
All right.
So I hope it's clear it's very important that you understand this.
And now, well, I have to say congratulations,
because we're actually done implementing our final tool.
And of course I'm going to show you the result of feature scaling here.
So let me create two more code cells inside
which we're going to print first X train.
And then let me copy this.
And then we're going to print X test.
All right.
So let's first run this to apply feature scaling.
Perfect. There we go. No execution error.
Then let's print X train.
And of course we get well still the same values
for the dummy variables which are indeed still between minus three and plus three.
But then our age and salary variables were transformed
so that they take new values between minus two and plus two.
Sometimes you will see values between minus three and plus three.
Here it's minus two and plus two.
But anyway, now all our variables
are on the same scale and this will be perfect to improve
or optimize the training of certain machine learning models.
And of course you will see exactly which ones they're going to be.
The further we progress in this machine learning course.
So now you know everything.
Let's also execute this cell to print X test.
And once again will
you still have your dummy variables here for the same to customers that were here.
But then the age and the salary were scaled
so that they take once again values between minus two and plus two.
All right okay. So great.
I'm really happy that we are now done
with this data preprocessing toolkit, because that means only one thing.
That means that we are ready to start the exciting steps of the journey,
which is to build machine learning models that will perform amazing predictions.
And we're going to start with the regression models,
which will predict some continuous numerical values.
And we will learn how to do that on different data sets.
But before we move on to this next part, I just want to show you the data
preprocessing template, which will be so useful for us
to tackle in the Fleshlight, the data preprocessing
phase for each of our future machine learning models.
Because indeed, you will see that this template was made
so that we will only have each time
1 or 2 things to change, and most of the time one thing to change.
Because indeed, in this template I included the three always used tools
that we will use for our machinery models, which are importing the libraries.
Right?
We will always need these libraries, then importing the data set.
And here appreciate that
we will only have one thing to change, which will be the name of the data set,
because indeed, this line of code will automatically
take all the columns except the last one, meaning all your features.
And this line of code will take automatically the dependent variable.
So here you will only have the name of the data set to change.
And then of course I included this tool because for most of our machinery models
we will have to split the data set into these two separate sets.
One training set
to train our machinery model and one to set to evaluate its performance.
And here, once again, we will actually have nothing to change.
So in the whole template,
we will only have one thing to change, which will be the name of the data set.
And that's why this data preprocessing template will be so useful for us,
because we will each time tackle the data preprocessing phase in flashlight.
So make sure to have this template ready each time.
We're going to build our future machine learning models.
And now take a good break.
You really deserve it.
After this data preprocessing phase.
And this answers to the questions that reduce any confusion.
So digest it well.
And as soon as you're ready
to tackle the first branch of machine learning model, which is regression,
well, let's continue our journey together in this next part.
And until then, enjoy machine learning.