'Predict the class labels for the provided data
Parameters
X : array-like, shape (n_query, n_features),                 or (n_query, n_indexed) if metric == \'precomputed\'
Test samples.
Returns
y : array of shape [n_samples] or [n_samples, n_outputs]
Class labels for each data sample.'

def predict(self, X):

    X = check_array(X, accept_sparse='csr')
    (neigh_dist, neigh_ind) = self.kneighbors(X)
    classes_ = self.classes_
    _y = self._y
    if (not self.outputs_2d_):
        _y = self._y.reshape(((-1), 1))
        classes_ = [self.classes_]
    n_outputs = len(classes_)
    n_samples = X.shape[0]
    weights = _get_weights(neigh_dist, self.weights)
    y_pred = np.empty((n_samples, n_outputs), dtype=classes_[0].dtype)
    for (k, classes_k) in enumerate(classes_):
        if (weights is None):
            (mode, _) = stats.mode(_y[(neigh_ind, k)], axis=1)
        else:
            (mode, _) = weighted_mode(_y[(neigh_ind, k)], weights, axis=1)
        mode = np.asarray(mode.ravel(), dtype=np.intp)
        y_pred[:, k] = classes_k.take(mode)
    if (not self.outputs_2d_):
        y_pred = y_pred.ravel()
    return y_pred
