Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the KNN algorithm do in the training phase?

Unlike other algorithms like linear regressions ,KNN doesn't seems to perform any calculation in the training phase. Like in case of linear regressions it finds the coefficients in the training phase.But what about KNN?

like image 686
user10418143 Avatar asked Feb 03 '19 17:02

user10418143


People also ask

Does KNN have a training phase?

Introduction. Lazy learning algorithm − KNN is a lazy learning algorithm because it does not have a specialized training phase and uses all the data for training while classification.

How the KNN algorithm performs during training and test processes?

In KNN, the training data points get stored, and no learning is performed. Validation data is to check the model performance, and the test data is used for prediction. To select optimal K, plot the error of model (error = 1 — accuracy) on training as well as on the validation dataset.

Why there is no training phase in KNN?

K-NN is a lazy learner because it doesn't learn a discriminative function from the training data but “memorizes” the training dataset instead. For example, the logistic regression algorithm learns its model weights (parameters) during training time. In contrast, there is no training time in K-NN.

Does KNN algorithm require training?

The model representation for KNN is the entire training dataset. It is as simple as that. KNN has no model other than storing the entire dataset, so there is no learning required.


1 Answers

During training phase, KNN arranges the data (sort of indexing process) in order to find the closest neighbors efficiently during the inference phase. Otherwise, it would have to compare each new case during inference with the whole dataset making it quite inefficient.

You can read more about it at: https://scikit-learn.org/stable/modules/neighbors.html#nearest-neighbor-algorithms

like image 127
J. Ferrarons Avatar answered Oct 21 '22 05:10

J. Ferrarons