Classification: K-Nearest Neighbors
K-Nearest Neighbors is a supervised machine learning algorithm for classification. You will implement and test this algorithm on several datasets.
StartKey Concepts
Review core concepts you need to learn to master this subject
KNN Classification Algorithm in Scikit Learn
K-Nearest Neighbors Underfitting and Overfitting
Euclidean Distance
Elbow Curve Validation Technique in K-Nearest Neighbor Algorithm
K-Nearest Neighbors
KNN of Unknown Data Point
Normalizing Data
KNN Classification Algorithm in Scikit Learn
KNN Classification Algorithm in Scikit Learn
from sklearn.neighbors import KNeighborsClassifier
KNNClassifier = KNeighborsClassifier(n_neighbors=5)
KNNClassifier.fit(X_train, y_train)
KNNClassifier.predict(X_test)
Scikit-learn is a very popular Machine Learning library in Python which provides a KNeighborsClassifier
object which performs the KNN classification. The n_neighbors
parameter passed to the KNeighborsClassifier
object sets the desired k
value that checks the k
closest neighbors for each unclassified point.
The object provides a .fit()
method which takes in training data and a .predict()
method which returns the classification of a set of data points.
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory