'Fit Ridge regression model
Parameters
X : array-like, shape = [n_samples, n_features]
Training data
y : array-like, shape = [n_samples] or [n_samples, n_targets]
Target values. Will be cast to X\'s dtype if necessary
sample_weight : float or array-like of shape [n_samples]
Sample weight
Returns
self : Returns self.'

def fit(self, X, y, sample_weight=None):

    if (self.cv is None):
        estimator = _RidgeGCV(self.alphas, fit_intercept=self.fit_intercept, normalize=self.normalize, scoring=self.scoring, gcv_mode=self.gcv_mode, store_cv_values=self.store_cv_values)
        estimator.fit(X, y, sample_weight=sample_weight)
        self.alpha_ = estimator.alpha_
        if self.store_cv_values:
            self.cv_values_ = estimator.cv_values_
    else:
        if self.store_cv_values:
            raise ValueError('cv!=None    and    store_cv_values=True        are    incompatible')
        parameters = {'alpha': self.alphas}
        gs = GridSearchCV(Ridge(fit_intercept=self.fit_intercept, normalize=self.normalize), parameters, cv=self.cv, scoring=self.scoring)
        gs.fit(X, y, sample_weight=sample_weight)
        estimator = gs.best_estimator_
        self.alpha_ = gs.best_estimator_.alpha
    self.coef_ = estimator.coef_
    self.intercept_ = estimator.intercept_
    return self
