class_docstr: Compute and store patterns from linear models.
  
  The linear model coefficients (filters) are used to extract discriminant
  neural sources from the measured data. This class computes the
  corresponding patterns of these linear filters to make them more
  interpretable :footcite:`HaufeEtAl2014`.
  
  Parameters
  ----------
  model : object | None
      A linear model from scikit-learn with a fit method
      that updates a ``coef_`` attribute.
      If None the model will be LogisticRegression.
  
  Attributes
  ----------
  filters_ : ndarray, shape ([n_targets], n_features)
      If fit, the filters used to decompose the data.
  patterns_ : ndarray, shape ([n_targets], n_features)
      If fit, the patterns used to restore M/EEG signals.
  
  See Also
  --------
  CSP
  mne.preprocessing.ICA
  mne.preprocessing.Xdawn
  
  Notes
  -----
  .. versionadded:: 0.10
  
  References
  ----------
  .. footbibliography::
class_docstr_tok: ["Compute","and","store","patterns","from","linear","models",".","The","linear","model","coefficients","(","filters",")","are","used","to","extract","discriminant","neural","sources","from","the","measured","data",".","This","class","computes","the","corresponding","patterns","of","these","linear","filters","to","make","them","more","interpretable",":","footcite",":","`","HaufeEtAl2014","`",".","Parameters","--","--","--","--","--","model",":","object","|","None","A","linear","model","from","scikit-learn","with","a","fit","method","that","updates","a","``","coef_","``","attribute",".","If","None","the","model","will","be","LogisticRegression",".","Attributes","--","--","--","--","--","filters_",":","ndarray",",","shape","(","[","n_targets","]",",","n_features",")","If","fit",",","the","filters","used","to","decompose","the","data",".","patterns_",":","ndarray",",","shape","(","[","n_targets","]",",","n_features",")","If","fit",",","the","patterns","used","to","restore","M\/EEG","signals",".","See","Also","--","--","--","--","CSP","mne.preprocessing.ICA","mne.preprocessing.Xdawn","Notes","--","--","-","..","versionadded",":",":","0.10","References","--","--","--","--","--","..","footbibliography",":",":"]
docstr: 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.
  **fit_params : dict of string -> object
      Parameters to pass to the fit method of the estimator.
  
  Returns
  -------
  self : instance of LinearModel
      Returns the modified instance.
docstr_tok: ["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",".","*","*","fit_params",":","dict","of","string","-",">","object","Parameters","to","pass","to","the","fit","method","of","the","estimator",".","Returns","--","--","--","-","self",":","instance","of","LinearModel","Returns","the","modified","instance","."]
code: def fit(self, X, y, **fit_params):
      """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.
      **fit_params : dict of string -> object
          Parameters to pass to the fit method of the estimator.
  
      Returns
      -------
      self : instance of LinearModel
          Returns the modified instance.
      """
      X, y = np.asarray(X), np.asarray(y)
      if X.ndim != 2:
          raise ValueError(
              f"LinearModel only accepts 2-dimensional X, got {X.shape} instead."
          )
      if y.ndim > 2:
          raise ValueError(
              f"LinearModel only accepts up to 2-dimensional y, got {y.shape} "
              "instead."
          )
  
      # fit the Model
      self.model.fit(X, y, **fit_params)
  
      # Computes patterns using Haufe's trick: A = Cov_X . W . Precision_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
  
imports: import datetime
  import numbers
  import numpy
  from ..fixes import BaseEstimator, _check_fit_params, _get_check_scoring
  from ..parallel import parallel_func
  from ..utils import verbose, warn
label_desc: Use image node_id 5 for calling the LinearModel obj's underlying member method code with example usage: obj.fit(X, y) and returns: self