/Scratch-implementation-of-KNN

This research is used to discover how to implement the k-Nearest Neighbors algorithm from scratch with Python.

Primary LanguageJupyter Notebook

KNN from scratch

knn_researchproject

mail sunilghimire64@gmail.com or (https://sunilghimire.com.np/) for more concrete understanding.

This research is used to discover how to implement the k-Nearest Neighbors algorithm from scratch with Python.

KNN concepts can hardly be described in a simpler way. It is an ancient expression that can be used in dozens of languages and traditions. In other terms, it is also said in the Bible: “He who walks with wise men will be wise, but the compassion of fools will suffer harm.”. It implies the idea of k-nearest neighbor classifiers is part of our everyday existence and judging.

K nearest neighbors or KNN algorithm is a straightforward algorithm that uses the whole dataset in its training dataset. Whenever a prediction is made for an unknown data instance, it looks for the k-most similar across the entire testing dataset, and eventually returns the data with the most similar instances as the predictions. KNN is often used when searching for similar items, such as finding items similar to this one.The Algorithm suggests that you are one of them because you are close to your neighbors.

To conduct grouping, the KNN algorithm uses a very basic method to perform classification. When a new example is tested, it searches at the training data and seeks the k training examples which are similar to the new example. It then assigns to the test example of the most similar class label.

K in KNN algorithm represents the number of nearest neighboring points that vote for a new class of test data. If k = 1, then test examples in the training set will be given the same label as the nearest example. If k = 3 is checked for the labels of the three closest classes and the most common i.e. occurring at least twice, the label is assigned for larger k’s and so on

Specifically, this research will focused on below points:

  1. How to code the k-Nearest Neighbors algorithm step-by-step.
  2. How to evaluate k-Nearest Neighbors on a real dataset.
  3. How to use k-Nearest Neighbors to make a prediction for new data.

💥 ESSENCE OF THE KNN ALGORITHM IN ONE PICTURE!

KNN_algorithm