Understanding classification using nearest neighbors