sega_learn.utils.decomposition

 
Modules
       
numpy

 
Classes
       
builtins.object
PCA
SVD

 
class PCA(builtins.object)
    PCA(n_components)
 
Principal Component Analysis (PCA) implementation.
 
  Methods defined here:
__init__(self, n_components)
Initializes the PCA model.
 
Args:
    n_components: (int) - Number of principal components to keep.
fit(self, X)
Fits the PCA model to the data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if n_components exceeds the number of features.
fit_transform(self, X)
Fits the PCA model and applies dimensionality reduction on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the principal component space of shape (n_samples, n_components).
get_components(self)
Retrieves the principal components.
 
Returns:
    components_: (np.ndarray) - Array of principal components of shape (n_features, n_components).
get_explained_variance_ratio(self)
Retrieves the explained variance ratio.
 
Returns:
    explained_variance_ratio_: (np.ndarray) - Array of explained variance ratios for each principal component.
inverse_transform(self, X_reduced)
Reconstructs the original data from the reduced data.
 
Args:
    X_reduced: (np.ndarray) - Reduced data of shape (n_samples, n_components).
 
Returns:
    X_original: (np.ndarray) - Reconstructed data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array.
transform(self, X)
Applies dimensionality reduction on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the principal component space of shape (n_samples, n_components).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if its dimensions do not match the fitted data.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class SVD(builtins.object)
    SVD(n_components)
 
Singular Value Decomposition (SVD) implementation.
 
  Methods defined here:
__init__(self, n_components)
Initializes the SVD model.
 
Args:
    n_components: (int) - Number of singular values and vectors to keep.
fit(self, X)
Fits the SVD model to the data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Raises:
    ValueError: If input data is not a 2D numpy array or if n_components exceeds the minimum dimension of the input data.
fit_transform(self, X)
Fits the SVD model and applies the transformation on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the singular value space of shape (n_samples, n_components).
get_singular_values(self)
Retrieves the singular values.
 
Returns:
    S: (np.ndarray) - Array of singular values of shape (n_components,).
get_singular_vectors(self)
Retrieves the singular vectors.
 
Returns:
    U: (np.ndarray) - Left singular vectors of shape (n_samples, n_components).
    Vt: (np.ndarray) - Right singular vectors of shape (n_components, n_features).
transform(self, X)
Applies the SVD transformation on the input data.
 
Args:
    X: (np.ndarray) - Input data of shape (n_samples, n_features).
 
Returns:
    X_transformed: (np.ndarray) - Data transformed into the singular value space of shape (n_samples, n_components).
 
Raises:
    ValueError: If input data is not a 2D numpy array.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object