Week 7 Part 1KNN K Nearest Neighbor Classification
Week 7 Part 1KNN K Nearest Neighbor Classification
K-NN
K-Nearest Neighbors (KNN) is a simple and versatile
machine learning algorithm used for both
classification and regression tasks.
It's based on the principle of similarity, where the
predicted label or value of a new data point is
determined by the labels or values of its k nearest
neighbors in the training dataset.
How KNN works?
Weaknesses:
Small K: A very small K can lead to overfitting, where the KNN algorithm becomes too
sensitive to noise and local variations in the training data, resulting in poor generalization to
unseen data.
Large K: A very large K can lead to underfitting, where the KNN algorithm becomes insensitive
to local patterns and fails to learn the underlying relationships between features and target
variables.
Odd K: Choosing an odd K value helps to break ties when voting for the class of a new data
point.
When do we use k-NN
How does k-NN algorithm works?
How does k-NN algorithm work?
Euclidean distance to find NN
Euclidian Distance formula
Distance calculation using Ecludian
Euclidian distance
K=3
Majority neighbors
Usecase2: apply nearest neighbor
algorithm from node-B
K-NN solution
Recap of k-NN
Use case3
K-NN predict diabetes
Diabetes dataset
Diabetes predict
K-NN classification recap
k-NN
Usecase4
Similarity
K-NN Usecase solution contd..
Rank these attributes
k=1
K=2
K=3
End of Week6 Part-1
• End of Week6 (Part1)
KNN-K Nearest Neighbor
Classification
Solved numerical on KNN classification
3 Nearest values N1,N2,N3
KNN solved example
End of Solved Usecases of
week7-part-1
• End of Solved Usecases