incremental_variance_threshold
Bases: feature_selection
Incremental variance-based feature selection.
This class selects features based on their variance, either by applying a threshold or selecting a fixed number of features with the highest variance. It supports incremental updates to the variance estimates.
Attributes:
Name | Type | Description |
---|---|---|
threshold |
float
|
The minimum variance threshold for feature selection. |
v |
Tensor or None
|
The current variance estimates for each feature. |
t |
int or None
|
The iteration count for incremental updates. |
Methods:
Name | Description |
---|---|
update_n_feature |
Update the number of features to select. |
update_threshold |
Update the variance threshold for feature selection. |
update_v |
Incrementally update the variance estimates. |
fit |
Compute variance estimates for the input data. |
transform |
Select features based on the variance estimates. |
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
__init__(threshold=0.0, name='incremental_variance_threshold', *args, **kwargs)
Initialize the incremental variance threshold feature selection class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
threshold
|
float
|
The minimum variance threshold for feature selection. Default is 0.0. |
0.0
|
name
|
str
|
The name of the feature selection method. Default is 'incremental_variance_threshold'. |
'incremental_variance_threshold'
|
*args
|
Additional arguments for the base class. |
()
|
|
**kwargs
|
Additional arguments for the base class. |
()
|
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.py
fit(X, device='cpu', *args, **kwargs)
Compute variance estimates for the input data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
Union[ndarray, Tensor]
|
The input data for feature selection. |
required |
device
|
str
|
The device to use for computation ('cpu' or 'cuda'). Default is 'cpu'. |
'cpu'
|
*args
|
Additional arguments for the fitting process. |
()
|
|
**kwargs
|
Additional arguments for the fitting process. |
()
|
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.py
transform(X, device='cpu', *args, **kwargs)
Select features based on the variance estimates.
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 input data with selected features. |
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.py
update_n_feature(new_n_feature)
Update the number of features to select.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_n_feature
|
int
|
The new number of features to select. |
required |
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.py
update_threshold(new_threshold)
Update the variance threshold for feature selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_threshold
|
float
|
The new variance threshold. |
required |
Source code in tinybig/koala/machine_learning/feature_selection/incremental_variance_threshold.py
update_v(new_v)
Incrementally update the variance estimates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_v
|
Tensor
|
The new variance estimates to update or replace the current estimates. |
required |