PCA#

class PCA(rescale_with_mean=True, rescale_with_std=True, n_components=2, n_iter=2, copy=True, check_input=True, random_state=None, engine='auto')[source]#

Bases: BaseEstimator, TransformerMixin

Principal Component Analysis. Used by RuleTreeCluster for numerical data.

Parameters:
  • rescale_with_mean (bool, default=True) – Whether to subtract the mean of each column.

  • rescale_with_std (bool, default=True) – Whether to divide each column by its standard deviation.

  • n_components (int, default=2) – Number of principal components.

  • n_iter (int, default=2) – Number of iterations of the randomized SVD.

  • copy (bool, default=True) – Whether to copy the data.

  • check_input (bool, default=True) – Whether to check the input.

  • random_state (int, default=None) – Seed of the SVD.

  • engine ({'auto', 'sklearn', 'fbpca'}, default='auto') – SVD implementation.

fit(X, y=None)[source]#

Fit the PCA.

Parameters:
  • X (array-like of shape (n_samples, n_features))

  • y (None) – Not used.

Returns:

self

Return type:

PCA

transform(X)[source]#

Computes the row principal coordinates of a dataset.

Same as calling row_coordinates. In most cases you should be using the same dataset as you did when calling the fit method. You might however also want to included supplementary data.

invert_transform(X)[source]#

Map X back to the original space: X @ components_ (whitening is not inverted).

fit_transform(X, y=None)[source]#

Fit the PCA and return the row principal coordinates.

Parameters:
  • X (array-like of shape (n_samples, n_features))

  • y (None) – Not used.

Returns:

coordinates

Return type:

numpy.ndarray of shape (n_samples, n_components)

column_correlation(X, same_input=True)[source]#

Returns the column correlations with each principal component.

property explained_variance_#

Returns the eigenvalues associated with each principal component.

property explained_variance_ratio_#

Returns the percentage of explained inertia per principal component.