Source: https://sebastianraschka.com/pdf/lecture-notes/stat479fs19/02-knn__notes.pdf