# noqa: D100
#%%
import numpy as np
from sklearn.base import BaseEstimator, ClassifierMixin
from sklearn.utils.validation import check_X_y, check_is_fitted
from sklearn.utils.validation import check_array

#%%
class OneNearestNeighbor(BaseEstimator, ClassifierMixin):
    """Define a classifier to find the nearest point of the
    """
    def __init__(self):  # noqa: D107
        pass

    def fit(self, X, y):
        """Train the model by fitting the model to the labelled data
        ----------------------
        Parameters : 

        X: observations of the training set (numpy array)
        """
        X, y = check_X_y(X, y)
        self.classes_ = np.unique(y)
        # XXX fix
        return self

    def predict(self, X):
        """Write docstring
        """
        check_is_fitted(self)
        X = check_array(X)
        y_pred = np.full(shape=len(X), fill_value=self.classes_[0])
        # XXX fix
        return y_pred

    def score(self, X, y):
        """Write docstring
        """
        X, y = check_X_y(X, y)
        y_pred = self.predict(X)
        return np.mean(y_pred == y)
