X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
Y = np.array([-1, -1, -2, 1, 1, 2])
nbrs = KNeighborsClassifier(n_neighbors=4, algorithm='ball_tree', metric=
    mydist, metric_params={'power': 2})
nbrs.fit(X, Y)
nbrs.kneighbors(X)
Sklearn kNN usage with a user defined metric