KNN Activity
KNN Activity
Assel Kaiyrbek,
MTH600
Professor Mwanza
Introduction
The k- Nearest neighborhood (KNN)- is a machine learning algorithm which is used for
classification and regression tasks. It makes predictions based on similarity between data. The
idea of KNN is that data which are close to each other likely have similar characteristics (Robert
T 202.)
1. Data preparation
You need to choose k. Which is the number of nearest neighborhoods for consideration when
make a prediction. Smaller k less smooth than larger k to predictions.
3. Calculate distance
Select the smallest distance which is k data point you want to predict for.
5. Classification or Regression
In the case of classification tasks, choose the label which is most common to KNN. In case of
regression, calculate the average of the main values of the KNN.
6. Make prediction.
Example
You have an apple and banana, and they have features “weight” and “color”. You want to
classify a new fruit which is based on weight and color.
Data:
1. Calculate distance.
3. two of them are apples and one banana, which means prediction is APPLE.
Conclusion
Based on this example we found that KNN algorithm predicts that the fruit is an APPLE.
References