def predict(self, X):
""" A reference implementation of a prediction for a classifier.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The input samples.
Returns
-------
y : array of int of shape = [n_samples]
The label for each sample is the label of the closest sample
seen udring fit.
"""
# Check is fit had been called
check_is_fitted(self, ['X_', 'y_'])
# Input validation
X = check_array(X)
closest = np.argmin(euclidean_distances(X, self.X_), axis=1)
return self.y_[closest]
评论列表
文章目录