ComponentChooser

class lightning_pose.utils.pca.ComponentChooser[source]

Bases: object

Determine the number of PCA components to keep.

Attributes Summary

cumsum_explained_variance

Cumulative sum of the explained variance ratios of the fitted PCA object.

Methods Summary

__call__()

Return the number of PCA components to retain.

Attributes Documentation

cumsum_explained_variance

Cumulative sum of the explained variance ratios of the fitted PCA object.

Returns:

1-D array where index i is the fraction of variance explained by the first i+1 components.

Methods Documentation

__call__() int[source]

Return the number of PCA components to retain.

Returns:

Integer number of components.

Raises:

TypeError – if self.components_to_keep is neither int nor float.

__init__(fitted_pca_object: PCA, components_to_keep: int | float | None) None[source]

Initialize ComponentChooser.

Parameters:
  • fitted_pca_object – a fitted sklearn.decomposition.PCA or NaNPCA instance whose explained_variance_ratio_ attribute is used to select the number of components.

  • components_to_keep – criterion for selecting components. An int returns that exact count; a float in [0, 1] returns the minimum number of components needed to reach that cumulative explained-variance threshold; None keeps all components.

__new__(**kwargs)