#!/usr/bin/env python3
from sklearn.metrics import r2_score
import numpy as np


class BaselineModel(object):
    def get_params(self):
        return None

    def predict(self, X):
        return np.ones_like(X.index.values) * self._y_pred

    def score(self, X, y):
        y_true = y
        y_pred = np.ones_like(y_true) * self._y_pred
        return r2_score(y_true, y_pred)


class BaselineClassificationPrediction(BaselineModel):
    def fit(
        self, X, y,
    ):
        self.y_pred = y.mode()
        return self

    def predict(
        self, X,
    ):
        return self.y_pred


class BaselineRegressionPrediction(BaselineModel):
    def fit(self, X, y):
        self._y_pred = y.median()
        return self

[((16, 15, 16, 39), 'sklearn.metrics.r2_score', 'r2_score', ({(16, 24, 16, 30): 'y_true', (16, 32, 16, 38): 'y_pred'}, {}), '(y_true, y_pred)', False, 'from sklearn.metrics import r2_score\n'), ((11, 15, 11, 43), 'numpy.ones_like', 'np.ones_like', ({(11, 28, 11, 42): 'X.index.values'}, {}), '(X.index.values)', True, 'import numpy as np\n'), ((15, 17, 15, 37), 'numpy.ones_like', 'np.ones_like', ({(15, 30, 15, 36): 'y_true'}, {}), '(y_true)', True, 'import numpy as np\n')]