Skip to content

Instantly share code, notes, and snippets.

@RoaldSchuring
Created July 5, 2019 19:41
Show Gist options
  • Save RoaldSchuring/56832d6fd45822800c8de0f8cd2af689 to your computer and use it in GitHub Desktop.
Save RoaldSchuring/56832d6fd45822800c8de0f8cd2af689 to your computer and use it in GitHub Desktop.
predict_fn
def predict_fn(input_data, model):
input_data_reshaped = input_data.reshape(1, -1)
distance, indice = model.kneighbors(input_data_reshaped, 11)
distance_list = distance[0].tolist()[1:]
indice_list = indice[0].tolist()[1:]
nearest_neighbors = [distance_list, indice_list]
print('predict_fn output is', nearest_neighbors)
return np.array(nearest_neighbors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment