Compute K-nearest neighbors (KNN).

Free CAS MAS-II (Modern Actuarial Statistics II) lesson in Statistical Learning. 13 min read, ~1,886 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. Classifier: predict the majority class among the nearest training points. Regressor: predict the mean (or weighted mean) of the nearest training responses. Distance metric matters. Default is...

Read the full lesson, free →
Worked examples, audio narration, and practice. No signup to read.

What this lesson covers

Learning objectives

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