'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,) or (n_samples, n_targets)
Target values. Will be cast to X\'s dtype if necessary
Returns
self : object
returns an instance of self.'

def fit(self, X, y):

    (X, y) = check_X_y(X, y, multi_output=True, y_numeric=True)
    n_features = X.shape[1]
    (X, y, X_offset, y_offset, X_scale, Gram, Xy) = _pre_fit(X, y, None, self.precompute, self.normalize, self.fit_intercept, copy=True)
    if (y.ndim == 1):
        y = y[:, np.newaxis]
    if ((self.n_nonzero_coefs is None) and (self.tol is None)):
        self.n_nonzero_coefs_ = max(int((0.1 * n_features)), 1)
    else:
        self.n_nonzero_coefs_ = self.n_nonzero_coefs
    if (Gram is False):
        (coef_, self.n_iter_) = orthogonal_mp(X, y, self.n_nonzero_coefs_, self.tol, precompute=False, copy_X=True, return_n_iter=True)
    else:
        norms_sq = (np.sum((y ** 2), axis=0) if (self.tol is not None) else None)
        (coef_, self.n_iter_) = orthogonal_mp_gram(Gram, Xy=Xy, n_nonzero_coefs=self.n_nonzero_coefs_, tol=self.tol, norms_squared=norms_sq, copy_Gram=True, copy_Xy=True, return_n_iter=True)
    self.coef_ = coef_.T
    self._set_intercept(X_offset, y_offset, X_scale)
    return self
