What KNN can do?
Classification
Prediction
Idea behind KNN?
Find the nearest K neighbors to record to be classified.
Majority decision rule to classify the record.
3. Distance Use here
Euclidean Distance
Before calculation distance, we need scale dataset.
Assume we have two class,
New point : Pink point, if we have k = 5,
Pink point close to 3 blue points and 2 green points.
So, new point will be assigned to Blue.
Elbow Rules
We usually choose the lowest point in the validation error with K-value.
We may choose 10 in this situation
For KNN prediction, we have same procedures in classification, but for the prediction we will use the mean in the neighbors to predict as new point.
For the orange point, from graph, we think orange is close to A1, A2 and A3.
And we assume the value for A1 = 6 , A2 = 7, A3 = 7.
So our prediction for orange point is ( 6 + 7 + 7) /3 = 6.66
simplicity and lack of complexity
large dataset may fits well
Time consuming
More predictors requires more records
Need to decide k