Preprocessing
AbstractNormalization
Bases: OneToOneFeatureMixin, TransformerMixin, BaseEstimator
Abstract base class for normalization techniques.
All normalization classes should inherit from this class and implement
the transform and inverse_transform methods.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the normalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
AbstractNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the input data.
Parameters
X : np.ndarray Transformed data.
Returns
np.ndarray Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data.
Parameters
X : np.ndarray Input data.
Returns
np.ndarray Transformed data.
Source code in asf/preprocessing/performance_scaling.py
BoxCoxNormalization
Bases: AbstractNormalization
Normalization using Box-Cox transformation (Yeo-Johnson variant).
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the Box-Cox transformer to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
BoxCoxNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using Box-Cox transformation.
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
DummyNormalization
Bases: AbstractNormalization
Normalization that does not change the data.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the DummyNormalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
DummyNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data (no change).
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data (no change).
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
FeatureGroupSelector
Bases: BaseEstimator, TransformerMixin
A sklearn-compatible transformer that selects features based on feature groups.
This transformer filters input features to only include those belonging to the specified feature groups. It is designed to work with ASlib scenarios where features are organized into groups (feature steps).
Parameters
feature_groups : dict[str, Any] Dictionary mapping feature group names to their metadata. Each value should be a dict with a 'provides' key listing the feature names in that group, and optionally a 'requires' key listing prerequisite groups. selected_groups : list[str] | None, default=None List of feature group names to include. If None, all groups are included. validate_requirements : bool, default=True If True, validate that all required prerequisite groups are included when selecting a group.
Attributes
selected_features_ : list[str] List of feature names that will be selected after fitting.
Examples
feature_groups = { ... 'basic': {'provides': ['f1', 'f2']}, ... 'advanced': {'provides': ['f3', 'f4']} ... } selector = FeatureGroupSelector(feature_groups, selected_groups=['basic']) X = pd.DataFrame({'f1': [1], 'f2': [2], 'f3': [3], 'f4': [4]}) selector.fit_transform(X) f1 f2 0 1 2
Example with prerequisites
feature_groups = { ... 'Pre': {'provides': ['f1', 'f2']}, ... 'Basic': {'provides': ['f3', 'f4'], 'requires': ['Pre']} ... } selector = FeatureGroupSelector(feature_groups, selected_groups=['Basic'])
This will raise MissingPrerequisiteGroupError because 'Pre' is not selected
Source code in asf/preprocessing/feature_group_selector.py
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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
fit(X, y=None)
Fit the selector by determining which features to select.
Parameters
X : pd.DataFrame Input features. y : Any, default=None Not used, present for API compatibility.
Returns
FeatureGroupSelector The fitted selector instance.
Source code in asf/preprocessing/feature_group_selector.py
get_feature_names_out(input_features=None)
Get output feature names.
Parameters
input_features : Any, default=None Not used, present for API compatibility.
Returns
list[str] List of selected feature names.
Source code in asf/preprocessing/feature_group_selector.py
get_selected_groups_from_config(feature_groups, config, prefix='feature_group_')
staticmethod
Extract selected feature groups from a SMAC configuration.
Parameters
feature_groups : dict[str, Any] Dictionary of all feature groups. config : dict[str, Any] SMAC configuration dictionary. prefix : str, default="feature_group_" Prefix used for feature group parameters in the config.
Returns
dict[str, Any] or None Dictionary of selected feature groups, or None if no groups selected.
Source code in asf/preprocessing/feature_group_selector.py
transform(X)
Transform the input by selecting only the specified features.
Parameters
X : pd.DataFrame Input features.
Returns
pd.DataFrame DataFrame with only the selected features.
Source code in asf/preprocessing/feature_group_selector.py
validate_feature_group_selection(feature_groups, selected_groups)
staticmethod
Validate that a list of selected groups satisfies all prerequisites.
This is a static utility method that can be used to validate selections without creating a FeatureGroupSelector instance.
Parameters
feature_groups : dict[str, Any] Dictionary of all feature groups with their metadata. selected_groups : list[str] List of selected feature group names.
Raises
MissingPrerequisiteGroupError If a selected group requires another group that is not selected.
Source code in asf/preprocessing/feature_group_selector.py
InvSigmoidNormalization
Bases: AbstractNormalization
Normalization using inverse sigmoid scaling.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the InvSigmoidNormalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
InvSigmoidNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using inverse sigmoid scaling.
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
LogNormalization
Bases: AbstractNormalization
Normalization using logarithmic scaling.
Source code in asf/preprocessing/performance_scaling.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
__init__(base=10.0, eps=1e-06)
Initialize LogNormalization.
Parameters
base : float, default=10.0 Base of the logarithm. eps : float, default=1e-6 Small constant to avoid log(0).
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the LogNormalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
LogNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using logarithmic scaling.
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
MinMaxNormalization
Bases: AbstractNormalization
Normalization using Min-Max scaling.
Source code in asf/preprocessing/performance_scaling.py
__init__(feature_range=(0, 1))
Initialize MinMaxNormalization.
Parameters
feature_range : tuple[float, float], default=(0, 1) Desired range of transformed data.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the Min-Max scaler to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
MinMaxNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
X : np.ndarray Transformed data.
Returns
np.ndarray Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using Min-Max scaling.
Parameters
X : np.ndarray Input data.
Returns
np.ndarray Transformed data.
Source code in asf/preprocessing/performance_scaling.py
MissingPrerequisiteGroupError
Bases: ValueError
Raised when a feature group is selected without its required prerequisite groups.
NegExpNormalization
Bases: AbstractNormalization
Normalization using negative exponential scaling.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the NegExpNormalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
NegExpNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using negative exponential scaling.
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
SqrtNormalization
Bases: AbstractNormalization
Normalization using square root scaling.
Source code in asf/preprocessing/performance_scaling.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
__init__(eps=1e-06)
Initialize SqrtNormalization.
Parameters
eps : float, default=1e-6 Small constant to avoid sqrt(0).
fit(X, y=None, sample_weight=None)
Fit the SqrtNormalization model to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
SqrtNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
----------
X : np.ndarray
Transformed data.
Returns
np.ndarray
Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using square root scaling.
Parameters
----------
X : np.ndarray
Input data.
Returns
np.ndarray
Transformed data.
Source code in asf/preprocessing/performance_scaling.py
ZScoreNormalization
Bases: AbstractNormalization
Normalization using Z-Score scaling.
Source code in asf/preprocessing/performance_scaling.py
fit(X, y=None, sample_weight=None)
Fit the Z-Score scaler to the data.
Parameters
X : np.ndarray Input data. y : np.ndarray or None, default=None Target values. sample_weight : np.ndarray or None, default=None Sample weights.
Returns
ZScoreNormalization The fitted normalization instance.
Source code in asf/preprocessing/performance_scaling.py
inverse_transform(X)
Inverse transform the data back to the original scale.
Parameters
X : np.ndarray Transformed data.
Returns
np.ndarray Original data.
Source code in asf/preprocessing/performance_scaling.py
transform(X)
Transform the input data using Z-Score scaling.
Parameters
X : np.ndarray Input data.
Returns
np.ndarray Transformed data.
Source code in asf/preprocessing/performance_scaling.py
get_default_preprocessor(categorical_features=None, numerical_features=None)
Creates a default preprocessor for handling categorical and numerical features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categorical_features
|
list[str] | Callable | None
|
List of categorical feature names or a callable selector. Defaults to selecting object dtype columns. |
None
|
numerical_features
|
list[str] | Callable | None
|
List of numerical feature names or a callable selector. Defaults to selecting numeric dtype columns. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ColumnTransformer |
ColumnTransformer
|
A transformer that applies preprocessing pipelines to categorical and numerical features. |