In this lecture, we will learn how to create gain in modern and Biton.
If you remember in the auditory lectures, we discussed that before running game, then we need to sanitize
our independent variables.
So first, let's see how to standardize our X or independent variables.
We will need pre processing function from what a scalar.
So first we will import pre processing.
And then there is a function known as a standard scalar.
Using a standard scalar will fit our extreme data and create an object called scalar.
This is killer object contains all the information needed to transform our X variable.
To scale our extreme variable, we will use this is skill set that we created on our external data and
we will transform our extreme data using this scalar.
So what is scalar here is the object which contain all the information of standardizing this external
data.
And then we are transforming our external data using this scalar.
If I run this.
Similarly will create a separate scaler for our X test data will follow the same step.
We will use preprocessing or standard scalar and then will fit X test into this Ascender discolor.
So now this is scalar very.
And then all the information that we need to transform our X as variable.
We will use this skill set and we will use transform function to transform our X test and to X test.
Underscore is scale.
Let's have a look at this X underscored best underscore s.
You can see now all the variables are in the smaller range.
Earlier, some of the variables were in decimal.
Some of them were in hundreds or thousands.
Now, all of them are in the small range of values.
When we standardize any variable, we convert the mean off all the values of that.
We rebate to zero and the sender deviation of that variable to one.
Now we have a standardized over variable.
Now let's string Cain and model on our training dataset for CNN will follow the same step.
We will first import gain then from a Skillern and then we'll create an object.
CnF underscored kanon underscore the one with the function gayed neighbor classifier and and neighbors
as one if you remember.
You can set number of numbers and you can then classifier.
So here the value of KS one.
And we can be noted by and underscore neighbors equal to one.
Now we will use this object to footnote extreme and wide data and this model.
We have for today with more Morten.
If we want to create confusion, metrics of this model, we can just use confusion metrics and give
the widest.
And the predicted values of way and sort of basically writing the variable name.
I am giving the output of dysfunction.
I am first predicting the White House values using the predicate function on X test under SCOTUS.
And then I'm using this another argument via test, which is my original values to clear this confusion
metrics.
If you see this are the core values.
Thirty and twenty five.
And this other wrongly classified value, 99 granted, so we can find the accuracy.
Yes.
Fifty five divided by a hundred and two, which is the total number of observations.
Or we can radically calculated using the accuracy scale.
The accuracy photos were gaining more than with one name, but is zero point five three.
Now we can change this number of neighbors from one to any other integer.
Let's run this model for K equals three will follow the same step will first create an object.
C11 that Scott kanon underscore Scott three.
But here, what hyper parameter which is key is three then will fit our Ekstrand or Tanvi trend data.
And to this new object.
And then will Derrick Lee find the accuracy scored from a world wide test and the predicted value of
by test using this model.
Let's run this to find out the accuracy.