acore.decomposition.pca module

Contents

acore.decomposition.pca module#

run_pca(df_wide: DataFrame, n_components: int = 2) tuple[DataFrame, PCA][source]#

Run PCA on DataFrame using sklearn.decomposition.PCA.

Parameters:
  • df (pd.DataFrame) – DataFrame in wide format to fit features on.

  • n_components (int, optional) – Number of Principal Components to fit, by default 2

Returns:

principal components of DataFrame with same indices as in original DataFrame, and fitted PCA model of sklearn

Return type:

Tuple[pd.DataFrame, sklearn.decomposition.PCA]