'Fit the model using X, y as training data.
Parameters
X : array-like, shape (n_samples, n_features)
Training data.
y : array-like, shape (n_samples,)
Target values.
Returns
self : object
returns an instance of self.'

def fit(self, X, y):

    (X, y) = check_X_y(X, y, y_numeric=True)
    X = as_float_array(X, copy=self.copy_X)
    y = as_float_array(y, copy=self.copy_X)
    cv = check_cv(self.cv, classifier=False)
    Gram = self.precompute
    if hasattr(Gram, '__array__'):
        warnings.warn(("Parameter    'precompute'    cannot    be    an    array    in    %s.    Automatically    switch    to    'auto'    instead." % self.__class__.__name__))
        Gram = 'auto'
    cv_paths = Parallel(n_jobs=self.n_jobs, verbose=self.verbose)((delayed(_lars_path_residues)(X[train], y[train], X[test], y[test], Gram=Gram, copy=False, method=self.method, verbose=max(0, (self.verbose - 1)), normalize=self.normalize, fit_intercept=self.fit_intercept, max_iter=self.max_iter, eps=self.eps, positive=self.positive) for (train, test) in cv.split(X, y)))
    all_alphas = np.concatenate(list(zip(*cv_paths))[0])
    all_alphas = np.unique(all_alphas)
    stride = int(max(1, int((len(all_alphas) / float(self.max_n_alphas)))))
    all_alphas = all_alphas[::stride]
    mse_path = np.empty((len(all_alphas), len(cv_paths)))
    for (index, (alphas, active, coefs, residues)) in enumerate(cv_paths):
        alphas = alphas[::(-1)]
        residues = residues[::(-1)]
        if (alphas[0] != 0):
            alphas = np.r_[(0, alphas)]
            residues = np.r_[(residues[(0, np.newaxis)], residues)]
        if (alphas[(-1)] != all_alphas[(-1)]):
            alphas = np.r_[(alphas, all_alphas[(-1)])]
            residues = np.r_[(residues, residues[((-1), np.newaxis)])]
        this_residues = interpolate.interp1d(alphas, residues, axis=0)(all_alphas)
        this_residues **= 2
        mse_path[:, index] = np.mean(this_residues, axis=(-1))
    mask = np.all(np.isfinite(mse_path), axis=(-1))
    all_alphas = all_alphas[mask]
    mse_path = mse_path[mask]
    i_best_alpha = np.argmin(mse_path.mean(axis=(-1)))
    best_alpha = all_alphas[i_best_alpha]
    self.alpha_ = best_alpha
    self.cv_alphas_ = all_alphas
    self.mse_path_ = mse_path
    self._fit(X, y, max_iter=self.max_iter, alpha=best_alpha, Xy=None, fit_path=True)
    return self
