Understanding nearest neighbor classification