incremental_random_projection
Bases: incremental_dimension_reduction
Incremental Random Projection for dimensionality reduction.
This class utilizes SparseRandomProjection
from sklearn.random_projection
to perform random projection
for dimensionality reduction in an incremental manner.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dimension reduction method. |
irp |
SparseRandomProjection
|
The underlying SparseRandomProjection model. |
n_feature |
int
|
The number of components to retain after random projection. |
Methods:
Name | Description |
---|---|
update_n_feature |
Update the number of components for the random projection model. |
fit |
Fit the random projection model to the input data. |
transform |
Transform the input data using the fitted random projection model. |
Source code in tinybig/koala/machine_learning/dimension_reduction/incremental_random_projection.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_random_projection', *args, **kwargs)
Initialize the incremental random projection model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dimension reduction method. Default is 'incremental_random_projection'. |
'incremental_random_projection'
|
*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_random_projection.py
fit(X, device='cpu', *args, **kwargs)
Fit the random projection 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_random_projection.py
transform(X, device='cpu', *args, **kwargs)
Transform the input data using the fitted random projection 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_random_projection.py
update_n_feature(new_n_feature)
Update the number of components for the random projection model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_n_feature
|
int
|
The new number of components to retain. |
required |