Compute K-nearest neighbors (KNN).

Free CAS MAS-II (Modern Actuarial Statistics II) lesson in Statistical Learning. 14 min read, ~2,049 words.

KNN is non-parametric and memory-based. Training cost is zero; prediction cost is per query because every test point scans the entire training set, where is the training set size. Classifier: predict the majority (plurality) class among the nearest training points. Regressor: predict the mean (or weighted mean) of the nearest...

Read the full lesson, free →
Worked examples and practice. Free with a free account, no card.

What this lesson covers

Learning objectives

Browse all free MAS-II lessons or jump into free MAS-II practice questions.