aNet.ai
Machine Learning/Learning path
0day streak0XP · Lv 1
← 12. Nearest-Neighbor & Probabilistic Methods
Lesson 2 of 4 8 min · 124 words

Distance measures for k-NN

Manhattan, Euclidean and others, and why features must be scaled.

k-NN depends entirely on its notion of 'close'. Common choices:

  • Euclidean (L2): — the default.\n- Manhattan (L1): — less sensitive to one large coordinate difference.\n- Minkowski: — generalises both.\n- Cosine distance: — for text and embeddings, where direction matters more than length.\n- Hamming: count of differing positions — for categorical or binary features.

Scaling is essential. If income ranges up to 100,000 and age up to 100, Euclidean distance is almost entirely income. Standardise (z-score) or min-max scale every feature first.

In high dimensions, distances between all points become similar (the curse of dimensionality), and 'nearest' loses meaning. Reduce dimensions with PCA or feature selection before using k-NN.

Formula to remember

Naïve Bayes

Prior × product of per-feature likelihoods.

Quick check · +5 XP

Naïve Bayes assumes features are…

Practice this topic
Saved in this browser as you type.
aNet.ai · Introduction to Machine Learning · NewUU course outlineProgress saved in this browser