In this video, we will learn the intuition behind our nearest neighbors classifier.
CNN is another approach which attempts to classify basis based classify it.
That is what a given observation based on the conditional probability of belonging to each class.
It will classify the observation into each class.
As we saw in Alioto.
Mark, unlike Ali, Gannon, is a non parametric mentor.
That is in Kinnon.
We do not assume any functional form of the relationship.
Therefore, the final go can have very complex chip.
Also, potentially, the final go can have very high accuracy, too.
Let me clean the content behind CNN using this simple diagram.
For simplicity, we are assuming that we have only two predictive variables so that I can short on a
two day plot.
Although the same concept can be extended for any number of predictors.
So suppose I have one predictor on the x axis and the other one on the Y axis and decollete of of these
small circles which represent each data point is telling us the class of the responsibility.
But that is some circles are an orange color.
So that is one class and somewhat in Blue-Collar.
Now, I have this point, which is Mondelēz X and I want to classify in2 either blue glass or the orange
glass, engage nearest neighbors.
We decide the value of key.
That is how many point near that particular point we want to consider.
So suppose I take is equal to three.
That is, I will take three nearest points to that point and out of those three.
I find the conditional probability of each class blue or orange.
So if you look at this point, I'm brown, the smaller circle, which can and Kompass do three point
so that I have the three nearest neighbors out of these three to belong to the blue category.
Therefore, the conditional probability of blue is to Vetri and one belongs to orange.
Never conditional release.
One by three.
Since the conditional probability of blue category is higher, I will assign this point.
Magda's across to the blue category.
If I had gays equal to one, that is, I will decide only basis one nearest neighbor.
Then I will find the point nearest to this Crosspoint, which is probably this orange circle.
In that case, I will assign Ordenes category to this cross.
If we take gays equal to do, then these two point will be closer to these.
This Crosspoint, in that case, the orange category will be having a commissioner of a video point
for you.
And the blue will also be having a condition.
Where will they appoint in such a case?
Our software package will be assigning the class randomly.
So when I'm running this gain and in much of good package, I will be setting seed by setting seed.
We will both be getting these same random solutions.
So whenever the conditions for a release seem for two glasses and the software package randomly assigned
Stigler's, we both will get the same answers.
So setting seed will help us, getting the same answers that is reproducing.
That isn't too broad.
This graph, that is to identify the boundaries of this nearest neighbor classifier.
We have created a grid off point.
So for all the different values of X and Y, we have created a grid of points.
And you assigned that last to each of these points.
So you see all these points are in Blue-Collar.
All these points are Ulgen, Blue-Collar and these points are in orange color and all these points.
I mean, the classes based on this concept, only when do you assign categories to all these Green Point.
Wherever decollete off grid point is changing.
I've drawn this boundary and this is all we will get.
The boundary of the classifier.
And again, in this neighborhood.
One of the most important parameter in Kenya and its neighbor is the value of key gay is often called
the hyper barometer of Ganon classify a gay controls the flexibility of this boundary.
So if you look at this, go I gays equal to one, my classified will closely follow each individual
point.
So if I have a blue point here, it will closely follow this and the boundary will be very complicated
and will have a lot of twists and turns.
Whereas if I use a very high value of key, the boundary will not be very sensitive to individual data
point.
It is having very less dones.
So the flexibility of this boundary is being go on by the value of key.
It is very important that we choose the optimal value of K so that we get the date of which it is entered
by Distorter Lane, which.
As the minimum edited, so since then we have gains you could look under, a lot of points were getting
misclassified when we have Gaige equal to one.
A lot of point.
Again, get misclassified.
Although the training at a rate will be very low when gays are equal to one.
My deepest Adelaide will be very high because this girl is too dependent on these individual values
and may not be actually following the true function of relationship between the Predator and the responsibility.
But so both of these will have.
At Adelaide in the desert.
It is very important that we get the optimum value of cake, get our test at Adelaide is minimum.
Another important thing to notice, because the and classify it predicts declasse of a given test observation
by identifying the observations that are nearest to it.
The scale of variables matters.
Any variables that are on a large scale will have a much larger effect on the distance between the observations
and hands on the can and classify it then the variables that are on a smaller scale.
For instance, imagine a dataset that contains two variables Salvy and age.
As far as CNN is concerned, a difference of a thousand dollars in salary is enormous compared to a
difference of 50 years in age.
Consequently, salary will drive dickin in classification results and age will have almost no effect.
This is contrary to our intuition that salary difference of thousand dollar is quite small compared
to in is defense of 50 years.
A good way to handle this problem is to standardize the data so that all variables are given a mean
of zero and a standard deviation of one.
Then all variables will be on a compatible skin to standardize data in the background.
Our software package will be using a formula like this.
We do not need to bother about it.
And just doing it for your students who would like to know what happened in the background.
We just follow this formula to standardize all the variables in our dataset.
We learn how to standardize variables in that software package.
In becoming video.