k-nearest neighbor algorithm using Python