K-Nearest-Neighbors-KNN-A-Fundamental-Machine-Learning-Algorithm (1).pptx
K-Nearest-Neighbors-KNN-A-Fundamental-Machine-Learning-Algorithm (1).pptx
by SHARON ELIZABETH
SONNY
What is K-Nearest Neighbors?
Algorithm Basics How it Works
KNN is a non-parametric, instance-based learning KNN finds the K closest neighbors in feature space. It
algorithm. It classifies data based on proximity to uses these neighbors to make predictions about new
known data points. The core principle: "Similar data points.
instances belong to similar classes."
Mathematical Foundation
Weighted distance calculations can be used for nuanced predictions. This adjusts the influence of each neighbor
based on its distance.
Algorithm Workflow
Select K
Choose the number of neighbors (K).
Calculate Distance
Calculate distance to all training points.
Identify Neighbors
Identify the K nearest neighbors.
Make Prediction
Use majority vote (classification) or average
(regression).
Choosing the Right K Value
Optimization
Use cross-validation for optimal K selection. Odd K values
prevent tied votes.
Strengths of KNN
Sensitive to Features
Requires feature
scaling.