class_docstr: Principal Component Analysis Class
  
  Parameters
  ----------
  n_components : int (default: None)
      The number of principal components for transformation.
      Keeps the original dimensions of the dataset if `None`.
  solver : str (default: 'svd')
      Method for performing the matrix decomposition.
      {'eigen', 'svd'}
  whitening : bool (default: False)
      Performs whitening such that the covariance matrix of
      the transformed data will be the identity matrix.
  
  Attributes
  ----------
  w_ : array-like, shape=[n_features, n_components]
      Projection matrix
  e_vals_ : array-like, shape=[n_features]
      Eigenvalues in sorted order.
  e_vecs_ : array-like, shape=[n_features]
     Eigenvectors in sorted order.
  e_vals_normalized_ :  array-like, shape=[n_features]
      Normalized eigen values such that they sum up to 1.
      This is equal to what's often referred to as
      "explained variance ratios."
  loadings_ : array_like, shape=[n_features, n_features]
     The factor loadings of the original variables onto
     the principal components. The columns are the principal
     components, and the rows are the features loadings.
     For instance, the first column contains the loadings onto
     the first principal component. Note that the signs may
     be flipped depending on whether you use the 'eigen' or
     'svd' solver; this does not affect the interpretation
     of the loadings though.
  
  Examples
  -----------
  For usage examples, please see
  https://rasbt.github.io/mlxtend/user_guide/feature_extraction/PrincipalComponentAnalysis/
class_docstr_tok: ["Principal","Component","Analysis","Class","Parameters","--","--","--","--","--","n_components",":","int","(","default",":","None",")","The","number","of","principal","components","for","transformation",".","Keeps","the","original","dimensions","of","the","dataset","if","`","None","`",".","solver",":","str","(","default",":","'svd","'",")","Method","for","performing","the","matrix","decomposition",".","{","'eigen","'",",","'svd","'","}","whitening",":","bool","(","default",":","False",")","Performs","whitening","such","that","the","covariance","matrix","of","the","transformed","data","will","be","the","identity","matrix",".","Attributes","--","--","--","--","--","w_",":","array-like",",","shape=","[","n_features",",","n_components","]","Projection","matrix","e_vals_",":","array-like",",","shape=","[","n_features","]","Eigenvalues","in","sorted","order",".","e_vecs_",":","array-like",",","shape=","[","n_features","]","Eigenvectors","in","sorted","order",".","e_vals_normalized_",":","array-like",",","shape=","[","n_features","]","Normalized","eigen","values","such","that","they","sum","up","to","1",".","This","is","equal","to","what","'s","often","referred","to","as","``","explained","variance","ratios",".","''","loadings_",":","array_like",",","shape=","[","n_features",",","n_features","]","The","factor","loadings","of","the","original","variables","onto","the","principal","components",".","The","columns","are","the","principal","components",",","and","the","rows","are","the","features","loadings",".","For","instance",",","the","first","column","contains","the","loadings","onto","the","first","principal","component",".","Note","that","the","signs","may","be","flipped","depending","on","whether","you","use","the","'eigen","'","or","'svd","'","solver",";","this","does","not","affect","the","interpretation","of","the","loadings","though",".","Examples","--","--","--","--","--","-","For","usage","examples",",","please","see","https",":","\/\/rasbt.github.io\/mlxtend\/user_guide\/feature_extraction\/PrincipalComponentAnalysis\/"]
code: def _fit(self, X):
      n_samples = X.shape[0]
      n_features = X.shape[1]
      if self.n_components is None or self.n_components > n_features:
          n_components = n_features
      else:
          n_components = self.n_components
  
      if self.solver == "eigen":
          cov_mat = self._covariance_matrix(X)
          self.e_vals_, self.e_vecs_ = self._decomposition(
              cov_mat, n_samples
          )
      elif self.solver == "svd":
          self.e_vals_, self.e_vecs_ = self._decomposition(X, n_samples)
  
      self.w_ = self._projection_matrix(
          eig_vals=self.e_vals_,
          eig_vecs=self.e_vecs_,
          whitening=self.whitening,
          n_components=n_components,
      )
  
      tot = np.sum(self.e_vals_)
      self.e_vals_normalized_ = np.array(
          [(i / tot) for i in sorted(self.e_vals_, reverse=True)]
      )
      self.loadings_ = self._loadings()
      return self
  
file_path: mlxtend/mlxtend/feature_extraction/principal_component_analysis.py
imports: import numpy
  from .._base import _BaseModel
label_desc: Use image node_id 3 for calling the PrincipalComponentAnalysis obj's underlying member method code with example usage: obj._fit(X) and returns: self