All right.
Good. So now I'm going to give you the solution.
So first of all we're going to fit or scaler.
You know our standardization tool on the training set.
So I'm taking the training set first X train.
All right.
And then since I've just explained that we want
apply feature scaling on the dummy variables.
Well then that means that we will fit our standard scaler object
only on these two columns here containing the ages and the salaries.
And therefore here I'm going to take only the two columns here
for the age and the salary. And then of course all the rows.
And remember the trick to take all the rows
we just need to add a column, which means we are taking the range
from the lower bound to the upper bound, meaning everything.
And then to take the columns well.
Be careful this is what we have to look at.
Now this because indeed we want to take this column and this one.
And so now the question is what are the indexes of these columns.
Well remember that indexes in Python start from zero.
So this has index zero.
Then the second column has an x one and x two.
And this one has index with each column has index three.
And the salary column has index four.
But since I want to make this template as much generic as we can,
and since when you one hot encode your categorical variables,
they always automatically go as the first column.
Well we're going to do something even better.
We're going to specify the indexes we want here by three,
which is the index of the h column.
And then a simple column. Right.
Because this will take the range from the column of the next three,
which is the edge up to all the other columns.
You know, there is not a minus one here.
So this will take all the remaining columns from the H, meaning the age
and the salary. Basically, this will take these two columns.
And if you have a larger matrix of features with numerical values
in your feature as well, this will just take all the columns.
All right. So that's a little trick.
More elegant let's say.
And so now we are of course going to use our object
which we called as C from which.
Well we're going to use that fit method that will indeed
for each feature of X train compute the mean of the feature
meaning the mean of the age, and then the mean of the salary,
and then compute the standard deviation of the feature, the age and the salary.
And that's exactly what the fit method will do.
It will only compute the mean and the standard deviation of all the values.
And then you have the transform method that will indeed apply this formula by,
you know, transforming each of the values here of each feature
into this value resulting from this formula.
All right.
So it's important to understand the difference between fit and transform fit.
We'll just get the mean and standard deviation of each of your features.
And transform will apply this formula to indeed transform
your values so that they can all be in the same scale.
All right.
And now the good news is that one of the methods
of the standard scalar class is actually fit transform,
which of course will proceed to the two tools at the same time, meaning
it will fit your matrix of features to get the mean and standard deviation.
And then right after that, transform
all the values of the features to turn them into this formula.
All right.
So let's call this method right away to make it efficient.
You know fit underscore transform form then some parentheses.
And now obviously you know what to input inside this fit transform method.
Well that's of course exactly the same as Xtrain here
because indeed we will only apply feature scaling
to our numerical columns here containing non-integer values.
Right. Non dummy variables value.