How does KNN algorithm work ? What are the advantages and disadvantages of KNN ?

k-NN classification: Given a data point in the test set and a training set for which class labels are given, find the k nearest data points in the training set and target label is computed as the mode of the class label of the k nearest neighbours.

Advantages : Simple to implement. Can learn non-linear boundary, robust to noise in the input data.

Disadvantages: Inefficient since the entire training data is processed for every prediction. Time complexity is O(dMNlog(k)) where d is the dimension of the data M the size of training data and N the size of test data.

Leave a Reply

Your email address will not be published. Required fields are marked *