incremental_PCA
Bases: incremental_dimension_reduction
Incremental Principal Component Analysis (PCA) for dimensionality reduction.
This class leverages IncrementalPCA
from sklearn.decomposition
to perform PCA in an incremental manner,
enabling efficient processing of large datasets that cannot fit into memory.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dimension reduction method. |
ipca |
IncrementalPCA
|
The underlying incremental PCA model. |
n_feature |
int
|
The number of components to retain after PCA. |
Methods:
Name | Description |
---|---|
update_n_feature |
Update the number of components for the PCA model. |
fit |
Fit the incremental PCA model to the input data. |
transform |
Transform the input data using the fitted PCA model. |
Source code in tinybig/koala/machine_learning/dimension_reduction/incremental_PCA.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
__init__(name='incremental_PCA', *args, **kwargs)
Initialize the incremental PCA model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dimension reduction method. Default is 'incremental_PCA'. |
'incremental_PCA'
|
*args
|
Additional arguments passed to the parent class. |
()
|
|
**kwargs
|
Additional arguments passed to the parent class. |
()
|
Source code in tinybig/koala/machine_learning/dimension_reduction/incremental_PCA.py
fit(X, device='cpu', *args, **kwargs)
Fit the incremental PCA model to the input data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
Union[ndarray, Tensor]
|
The input data for fitting. |
required |
device
|
str
|
The device to use for computation ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
Additional arguments for the fit process. |
()
|
|
**kwargs
|
Additional arguments for the fit process. |
()
|
Source code in tinybig/koala/machine_learning/dimension_reduction/incremental_PCA.py
transform(X, device='cpu', *args, **kwargs)
Transform the input data using the fitted PCA model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
Union[ndarray, Tensor]
|
The input data to transform. |
required |
device
|
str
|
The device to use for computation ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
Additional arguments for the transformation process. |
()
|
|
**kwargs
|
Additional arguments for the transformation process. |
()
|
Returns:
Type | Description |
---|---|
Union[ndarray, Tensor]
|
The transformed data after dimensionality reduction. |
Source code in tinybig/koala/machine_learning/dimension_reduction/incremental_PCA.py
update_n_feature(new_n_feature)
Update the number of components for the PCA model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_n_feature
|
int
|
The new number of components to retain. |
required |