def score(self, X, y, metric='r2'):
    'Score the model'
    assert (metric in ['r2', 'rmse', 'mae']), "Metric not supported. Supported metrics are 'r2', 'rmse' and 'mae'"
    y_pred = self.predict(X)
    if (metric == 'r2'):
        score = r2_score(y, y_pred)
    elif (metric == 'rmse'):
        score = rmse_score(y, y_pred)
    elif (metric == 'mae'):
        score = mae_score(y, y_pred)
    return score
Score the model
def score(self, X, y, metric='r2'):
    
    assert (metric in ['r2', 'rmse', 'mae']), "Metric not supported. Supported metrics are 'r2', 'rmse' and 'mae'"
    y_pred = self.predict(X)
    if (metric == 'r2'):
        score = r2_score(y, y_pred)
    elif (metric == 'rmse'):
        score = rmse_score(y, y_pred)
    elif (metric == 'mae'):
        score = mae_score(y, y_pred)
    return score