'Estimate the coefficients of the linear model.
Save the coefficients in the attribute ``filters_`` and
computes the attribute ``patterns_``.
Parameters
X : array, shape (n_samples, n_features)
The training input samples to estimate the linear coefficients.
y : array, shape (n_samples, [n_targets])
The target values.
Returns
self : instance of LinearModel
Returns the modified instance.'

def fit(self, X, y):

    (X, y) = (np.asarray(X), np.asarray(y))
    if (X.ndim != 2):
        raise ValueError(('LinearModel    only    accepts    2-dimensional    X,    got    %s    instead.' % (X.shape,)))
    if (y.ndim > 2):
        raise ValueError(('LinearModel    only    accepts    up    to    2-dimensional    y,    got    %s    instead.' % (y.shape,)))
    self.model.fit(X, y)
    inv_Y = 1.0
    X = (X - X.mean(0, keepdims=True))
    if ((y.ndim == 2) and (y.shape[1] != 1)):
        y = (y - y.mean(0, keepdims=True))
        inv_Y = np.linalg.pinv(np.cov(y.T))
    self.patterns_ = np.cov(X.T).dot(self.filters_.T.dot(inv_Y)).T
    return self
