KNN is the most intuitive algorithm in machine learning. It follows a simple philosophy: 'Tell me who your neighbors are, and I'll tell you who you are.'
1The Neighborhood Rule
K-Nearest Neighbors (KNN) is a classification algorithm that predicts the label of a new data point based on the labels of the 'K' points closest to it. If K=5 and three neighbors are 'Spam' while two are 'Ham', the model predicts 'Spam' by majority vote.
2The Lazy Learner
KNN is known as a Lazy Learner because it doesn't build a mathematical model during the training phase. Instead, the .fit() method simply stores the training data. All the 'work' happens during the prediction phase, where the algorithm calculates distances to every stored point.
3Scaling is Mandatory
Because KNN relies on Euclidean distance, features with larger numerical ranges (like Salary) will completely dominate features with smaller ranges (like Age). To ensure a fair vote, you must always apply Feature Scaling before training a KNN model.
