Hello.
So today in this session, we are going to learn what exactly is this Gernon, which is nothing but
my key nearest neighbor's algorithm, which is used both of the cases, whether we have some classification
uses or whether we have some regression using it.
So it is used in both of the scenarios.
But yeah, there is some limitation to this canon.
So what what is that limitation?
So one hour, whenever you have huge data, so whenever you have some huge data, never used this again
because it is it is always advisable to data scientist whenever they are going to work for real.
One aspect, they are not the answer to that.
Yeah, you have to use this scanning.
Definitely because.
Because computation wise.
Computation wise, this CNN takes a lot of time.
It takes lots of time.
So definitely computation.
It is too much costly.
So there is not any disabusing kennen in real world scenario.
So whenever you are going to perform real what to expect whenever you have data in terms of like say
gee whiz, let's say in terabytes, in petabytes.
So whenever you have such a huge amount of data, always tried to ignore again.
And at that particular time, if you don't have that much huge amount of data.
Yeah, always, always go ahead of it.
This is not a major issue regarding that.
So let's talk about what exactly is this and what what what are the basics?
What what exactly the mathematics behind this so that it was let's understand, what is this key?
What exactly is this?
So this is nothing, but this is nothing but number of nearest neighbor's number of nearest neighbors
to are particular against the particular data point that that we have to calculate, that we have to
basically calculate.
So the question is how we have to calculate, how we have to calculate this this game for basically
the are two major approaches.
The very first one is just just to use this cross-validation, just to use our approach cross-validation
in which you can go ahead with this randomized CV that that often you have heard about it and exactly
what grid search c.v you can you can just go ahead with this and put some random value of, let's say,
two, three to 10 trillion.
And definitely you will get your best value of care suitable for your use case that that's what this
randomized search and this grid search will do.
So let me consider some very basic uses to explain it in a very easiest way.
Let me let let's let this has some data.
This is data that is plotted over here in your scatterplot.
Let's say this is entire data.
You you will say let's say the data and this circle should be the let's say the circles of data is exactly
of my next class one or of my level one.
Let's say this.
This is called shape is exactly my class to I can see it is my living.
Do whatever you get as it's all up to you support in the future whenever you are going to work on some
some project, let's say let's say some new data will come, let's say some new detail.
You can see your test data, you can say this test data or you can say it is my unseen data.
Let's say this is my unseen data on which I have to do some prediction depending upon depending upon
the source.
Let's see if I'm going to block the data point.
Let's say let's say this is exactly that data point, that this is exactly that data point.
And let's say you have to predict we have to predict this, this, this this data point that you have
mapped over here.
This will belong to either plus one or plus two.
So just think how you can put this to which plus two which plus this this data points belong to whether
it will belong to one or whether it belongs to plus two.
So, yeah, definitely, if you are going to use Kiana over here, yeah, this case is just like a piece
of cake, just like a piece of cake.
Yeah.
So let's say let's say let's say you are going to use Kenen over here to find this this datapoint belong
to which class.
So let's say I'm going to assume equal to three.
Just just hypothetically, I'm going to assume my gay values.
It means I'm going to consider three nearest neighbors to this data point three near Sibos to this data
point, not a question will arise.
How I will compute, how I will compute what are exactly my three nearest neighbors.
It means you have to use a concept of distance that what you have often had in your school is because
if let's say if I know distance between the state of mind to each other, data point with each other,
data that are scattered over here, I can definitely get to know what are my three nearest neighbors.
It means I have to use the concept of distance.
So definitely, if you have heard about something, if you have heard about this formula, which is
nothing but excellent, excellent scalper's, why to minus Viviana's Grand Huelskamp and this one,
this is nothing but just a distance between two points, distance between two points, having coded
it as X and Y one and x2 y2 in some.
In some plain.
In a two dimensional pain.
So basically this is a formula that you have often done in your school days or definitely you will you
will learn this in your school is now a question that arise.
What if, what if, what if I don't have it.
I don't have that.
I have some this data point is gathered in such a way that it is scattered in, let's say, in and dimensions
or in some teeny dimension.
So it means it means that we open a new page and nobody let me open it.
Yeah.
Let's say this is my data point to this data point and that this is a data point that we have to compute
the standard that let's say it's this, it's coordinates in three dimensional is X and Y and Z one.
And it is nothing but X to Y to Alexis.
Some some let's say you have to compute distance between, OK, so what we have to do, you have to
just use the formula, which is nothing but excellent as excellent a square form for your X coordinate
similar do a..
Why.
What is good for the Y coordinate.
Similarly something check two minus one for your chart government.
Similarly, if you have any dimensions it will get it will get expanded.
Simple it just like an expansion.
So this is exactly this is exactly my Euclidean distance.
You have heard, you have definitely heard about this.
This is exactly my Euclidean distance.
So basically Kinen uses this distance internally to find my plane nearest neighbors for that particular
data point for which I have to put in some use it Gearman Ganon also uses or you can also modify or
you can also modify, also modify something known as Manhattan distance.
So instead of using this this Euclidean distance at some particular places, you can use this Manhattan
distance.
So what exactly is this Manhattan distance?
So Manhattan distance is nothing.
But you can see it is just my absolute distance, if you have heard it is just my absolute distance
and and it has many names.
Let's say it.
What is your city block distance.
What is your city block.
So this is also my Manhattan distance.
Let's say you have heard your Alver not logician.
That is exactly Manhattan distance.
Let's say.
Let's see if I would ask you.
Yeah.
Tell me.
Yeah.
Let's say I am traveling from from point A to point it say to before from point X two point one.
Let's say, let's say this is my let's say this is my path and if I have to compute distance I can easily
go ahead with this, this, this Euclidean distance.
So definitely it has some it has some coordinates like the explanation and it has some Kornet extra
weight.
So I can definitely compute distance.
But what if it let me open a new page.
Yeah, but what if it I have to travel from point A to point why.
But but why are x1 x to x3.
Let's elected.
This is my next to this is my path.
That's a this is my path.
Let's say this is my Xoom.
Let's this is my X to it, this is my X three.
And if I will ask you.
Yeah.
How you can compute the distance between this, this X and distance between.
I can see this with X and Y how you can compute it.
So let's say I'm traveling, I'm traveling from point at.
To point why and I am going to say I have to compute its distance, so in such case, in such type of
use cases, I have to use our Manhattan distance, I have to use a word Manhattan distance, like like
how Google Maps you have heard, like how Google Maps and how all the other uses for definitely internally
they use this they uses this Manhattan distance to calculate distance between two places.
That's how the uses.
So basically using the approach, how, how they will compute.
So they will compute like this, like from this one and this then again this.
Then this.
And this and again, this, that, again, would moved from this, then again this, then again, that
again and again and I am going to reach it to my place.
So in this way, in this way, they can come up with some distance.
So this is exactly my this is exactly my Manhattan distance.
Or if I have to explain you in a very layman's terms and I can say, Febles, this this this Manhattan,
this place is nothing but calculating distance between real vectors using some of the absolute difference.
Yeah.
Similar similar similar problem statement.
Suppose suppose that this is my point X and this is my wife.
So basically this is exactly my this is exactly my this is exactly my Euclidean distance but.
Going from this way and again, going from this way, so whatever it will be, whatever it will be,
it is exactly my Manhattan distance.
Whereas whereas this is this is exactly my Euclidean distance and this is like, say, this is my rectory
and this is my Vectibix.
So summation of this victory and B is exactly my Manhattan.
That's a basic a very basic mathematics behind this Euclidian as well as Manhattan D.A. We have something
known as having dist..
Yeah, we have some quinonez.
We have something known as having this test, which we all are going to cover in our little session
that that we will basically use in terms of categorical data.
So whenever we have them, whenever we have to compute the between some categorical data, categorical
data and such type of use case, we have to use something known as this hanging distance.
So that is all about the basics of Ken and what is you clearly understand what is Manhattan distance?
We have also learned the basics behind this.
What is this use case?
What the value of K, how to compute value of K, basically using our cross validation approaches and
here I'm going to assume a value of K Street, then we have to solve this case as well.
So in the upcoming session we are going to solve this use case, whatever we have this value of K and
how you can set your nearest neighbor.
So that's all about the session.
Hope you love it very much.
Thank you.
Have a nice day.
Keep learning.
Keep growing.
Keep practicing.