k-nearest neighbors
k-nearest neighbors (KNN) is a simple and intuitive algorithm used in machine learning for classification and regression tasks. It works by finding the k closest data points in a dataset to a new data point and making predictions based on the majority class or average value of those neighbors. The "closeness" is usually measured using distance metrics like Euclidean distance.
When you want to classify a new item, KNN looks at the k nearest items in the training data. For example, if you want to classify a fruit as an apple or orange, KNN checks the nearest fruits in the dataset and assigns the label based on which fruit appears most frequently among those neighbors.