class_docstr: Base class for SparsePCA and MiniBatchSparsePCA
class_docstr_tok: ["Base","class","for","SparsePCA","and","MiniBatchSparsePCA"]
docstr: Fit the model from data in X.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Training vector, where `n_samples` is the number of samples
      and `n_features` is the number of features.
  
  y : Ignored
      Not used, present here for API consistency by convention.
  
  Returns
  -------
  self : object
      Returns the instance itself.
docstr_tok: ["Fit","the","model","from","data","in","X.","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Training","vector",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features",".","y",":","Ignored","Not","used",",","present","here","for","API","consistency","by","convention",".","Returns","--","--","--","-","self",":","object","Returns","the","instance","itself","."]
code: def fit(self, X, y=None):
      """Fit the model from data in X.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Training vector, where `n_samples` is the number of samples
          and `n_features` is the number of features.
  
      y : Ignored
          Not used, present here for API consistency by convention.
  
      Returns
      -------
      self : object
          Returns the instance itself.
      """
      random_state = check_random_state(self.random_state)
      X = self._validate_data(X)
  
      self.mean_ = X.mean(axis=0)
      X = X - self.mean_
  
      if self.n_components is None:
          n_components = X.shape[1]
      else:
          n_components = self.n_components
  
      return self._fit(X, n_components, random_state)
  
imports: from numbers import Integral, Real
  import numpy
  from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, TransformerMixin, _fit_context
  from ..linear_model import ridge_regression
  from ..utils import check_random_state
  from ..utils._param_validation import Hidden, Interval, StrOptions
  from ..utils.extmath import svd_flip
  from ..utils.validation import check_array, check_is_fitted
  from ._dict_learning import MiniBatchDictionaryLearning, dict_learning
label_desc: Use image node_id 2 for calling the _BaseSparsePCA obj's underlying member method code with example usage: obj.fit(X, y) and returns: self