In this video, we will learn how to build a cannon based classify skin and classify it uses a function
called gain in this function is part of the glass package.
You can see on the right there is a glass package if it is installed.
It will be shown here.
If it is tarnished all you first have to install it.
Using its target is function once you have started.
Just take it here so that it is active.
So this function the key and in function it requires for input.
The first input is a matrix containing the predictors associated with the training data.
That is all the independent variables.
The X variables should be segregated from the training data and put into a separate variable.
I'll name this very well as Train X.
So why train X variable?
We'll have all the variables of training data set except desalt variable, distorted variable is on
the sixteenth column position.
If you're not sure about it, you can you can open that data.
Scroll to the right and hold over the name of the variable.
This is column 16.
So we will remove the 16th column.
To do that, we will write green.
And of course, it will in square brackets, first parameter will be blank.
That is, we want all zeros, then a comma, then minus 16.
That is not the 16th column.
Everything else we have three.
The second parameter we require is the best predictor variables.
That is test X.
These variables, these observations will be classified by digging in classified, so this Test X will
be graded from the test set and tested.
Also has this old variable which has to be removed.
So they'll remove it by writing minus 16.
The third parameter can and function will take is a vector containing
glass labels for the training observation.
What does that mean?
It contains the Y, but even that is the sole variable for all the reading observations.
So train Y.
Is equal to drain dollar soared.
So does the dependent variable for which we know devalues.
And Test Wavery will again will be the dependent variable of be tested.
This will be used to compare the performance of the predicted values of Y against this test sort of
way.
But this test way is not the vote, but every day before that, and we don't know for certain.
D given you engage nearest neighbor.
I told you that we fixed the rally off nearest neighbor.
Be we consider that is the value of key.
We have to input that value of key.
So here we will use a key value of three first.
We'll create a variable called is equal to three.
I also told you that since kanon classify user distances, it is important that we standardize these
variables so that all the variables have an equal impact in terms of their scale.
So to standardize the variables, we use a variable called scale.
So the standardized version of the will be Tenex.
Code is.
Is equal to scale and within bracket.
We will give these tenex, but he would.
So, I mean, I leave, you will do it for mistakes.
We do not need to do this for divine variables because they are categorical and they do not need scaling.
One last thing that we have to do before running the and classify it is setting seed.
As I told you, whenever there is a time by assigning the class to an observation or a science class
randomly.
So when you are doing it and when I am doing it, we should both get the same reasons to do that.
We will set a seed by writing set seed zero.
If you do this, your design and manager will be exactly same.
So for the reproducibility of the desert, we are setting the seed.
Now we are ready to run again and classify it.
We will write candles and dark, Fred.
This is the variable name which will contain the result of the garden and model.
It starts with the gain and function.
The first barometer is train X under Skoda's.
Second, barometer's districts underscore this.
The third parameter is green light.
And the last word on that is D gave a news, look, gays equal to gay.
So this gay is.
But I made a name for this function and this gay is the variable name that I have to sign.
So here you can put gays equal to one, not gay is equal to three radically alter.
I've just put I've just say separated it here so that whenever I change the value of gay here I can
add on the whole analysis.
I mean, so let's run this.
So the model are stored in gain and.
If you want to create the confusion matrix, we will use this CNN prayed and the best way variable so
they are able to get in and prayed
Colma Bestway.
So get in prayer.
Has deep predicted values display as the actual values.
So here is our confusion, matrix using beginning classifier.
You can see we are getting 66 out of 120 correct responses, correct predictions and 54 incorrect predictions.
Now the JADI value of gate from three to one.
And then done this again.
You can see that now we are getting only fifty nine correct predictions on the desert.
That is a live we were getting 66 correct predictions.
You can see by changing the value of key, that is by increasing the flexibility of Deakin and model.
We get different accuracy of our gain in model.
So you can see this is the template of the gear nearest neighbor model.
We first get this class package.
Then we create X that sticks train Y Bestway.
And we assign a key value.
All these four will going to the gain and function to give us the predicted values.
Remember to standardize the values of all the dependent variables before putting it into the can and
model.
That's it.
And this we do.