sktime.transformations.panel.pca¶
-
class
sktime.transformations.panel.pca.
PCATransformer
(n_components=None, **kwargs)[source]¶ Bases:
sktime.transformations.base._PanelToPanelTransformer
Transformer that applies Principle Components Analysis to a univariate time series.
Provides a simple wrapper around
sklearn.decomposition.PCA
.- Parameters
n_components (int, float, str or None (default None)) – Number of principle components to retain. By default, all components are retained. See
sklearn.decomposition.PCA
documentation for a detailed description of all options.**kwargs – Additional parameters passed on to
sklearn.decomposition.PCA
. Seesklearn.decomposition.PCA
documentation for a detailed description of all options.
-
fit
(X, y=None)[source]¶ Fit transformer, finding all principal components.
- Parameters
X (nested pandas DataFrame of shape [n_samples, 1]) – Nested dataframe with univariate time-series in cells.
- Returns
self
- Return type
an instance of self.
-
transform
(X, y=None)[source]¶ Transform X, transforms univariate time-series using sklearn’s PCA class
- Parameters
X (nested pandas DataFrame of shape [n_samples, 1]) – Nested dataframe with univariate time-series in cells.
- Returns
Xt – Transformed pandas DataFrame with the same number of rows and the (potentially reduced) PCA transformed column. Time indices of the original column are replaced with 0:( n_components - 1).
- Return type
pandas DataFrame