TSCPrincipalComponent#

class datafold.dynfold.TSCPrincipalComponent(n_components=None, *, copy=True, whiten=False, svd_solver='auto', tol=0.0, iterated_power='auto', n_oversamples=10, power_iteration_normalizer='auto', random_state=None)[source]#

Bases: PCA, TSCTransformerMixin

Compute principal components from data.

This is a subclass of scikit-learn’s PCA to generalize the input and output of pandas.DataFrames and TSCDataFrame. All input parameters remain the same. For documentation please visit:

Methods Summary

fit(X[, y])

Compute the principal components from training data.

fit_transform(X[, y])

Compute principal components from data and reduce dimension on same data.

get_feature_names_out([input_features])

Get output feature names for transformation.

inverse_transform(X)

Map data from the reduced space back to the original space.

transform(X)

Apply dimension reduction by projecting the data on principal components.

Methods Documentation

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

Compute the principal components from training data.

Parameters:
Returns:

self

Return type:

TSCPrincipalComponent

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

Compute principal components from data and reduce dimension on same data.

Parameters:
Returns:

same type as X of shape (n_samples, n_components_)

Return type:

TSCDataFrame, pandas.DataFrame, numpy.ndarray

get_feature_names_out(input_features=None)[source]#

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: [“class_name0”, “class_name1”, “class_name2”].

Parameters:

input_features (array-like of str or None, default=None) – Only used to validate feature names with the names seen in fit().

Returns:

feature_names_out – Transformed feature names.

Return type:

ndarray of str objects

inverse_transform(X)[source]#

Map data from the reduced space back to the original space.

Parameters:

X (Union[TSCDataFrame, ndarray]) – Out-of-sample points of shape (n_samples, n_components_) to map back to original space.

Returns:

same type as X of shape (n_samples, n_features)

Return type:

TSCDataFrame, pandas.DataFrame, numpy.ndarray

transform(X)[source]#

Apply dimension reduction by projecting the data on principal components.

Parameters:

X (TSCDataFrame, pandas.DataFrame, numpy.ndarray) – Out-of-sample points of shape (n_samples, n_features) to perform dimension reduction on.

Returns:

same type as X of shape (n_samples, n_components_)

Return type:

TSCDataFrame, pandas.DataFrame, numpy.ndarray