Machine Learning & AI
Basic

Euclidean Distance (KNN)

Straight-line distance between two points; the default metric for k-nearest neighbours.

Formula

d(p,q)=i(piqi)2d(\mathbf{p},\mathbf{q}) = \sqrt{\sum_i (p_i-q_i)^2}

Variables

\mathbf{p},\mathbf{q}Two vectors
p_i,q_iComponents

Example

p=(0,0), q=(3,4): d=5

Did You Know?

KNN is a "lazy" learner — it does no training and simply memorises the data.

Share this formula