'Perform classification on an array of test vectors X.
The predicted class C for each sample in X is returned.
Parameters
X : array-like, shape = [n_samples, n_features]
Returns
C : array, shape = [n_samples]
Notes
If the metric constructor parameter is "precomputed", X is assumed to
be the distance matrix between the data to be predicted and
``self.centroids_``.'

def predict(self, X):

    check_is_fitted(self, 'centroids_')
    X = check_array(X, accept_sparse='csr')
    return self.classes_[pairwise_distances(X, self.centroids_, metric=self.metric).argmin(axis=1)]
