nirs4all.operators.transforms.features module
- class nirs4all.operators.transforms.features.CropTransformer(start: int = 0, end: int = None)[source]
Bases:
BaseEstimator,TransformerMixin
- class nirs4all.operators.transforms.features.FlattenPreprocessing(sources: str | int | List[int] = 'all')[source]
Bases:
BaseEstimator,TransformerMixinFlatten the preprocessing dimension of a 3D feature array.
Transforms a 3D array of shape (samples, preprocessings, features) into a 2D array of shape (samples, preprocessings * features) by horizontally concatenating all preprocessing views.
This is useful after feature_augmentation when you want to flatten multiple preprocessing views into a single feature vector for models that expect 2D input.
- Parameters:
sources – Which sources to apply the flattening to. - “all” (default): Apply to all sources - List of indices: [0, 2] to apply only to sources 0 and 2 - Single int: Apply to only that source If a source is not in the list, it is passed through unchanged.
Example
>>> # Input: (100, 4, 2151) - 4 preprocessing views of 2151 features each >>> flattener = FlattenPreprocessing() >>> output = flattener.transform(X) >>> # Output: (100, 8604) - 4 * 2151 = 8604 features
>>> # Apply only to specific sources >>> flattener = FlattenPreprocessing(sources=[0, 2]) >>> # Only sources 0 and 2 will be flattened
Note
If input is already 2D, it is returned unchanged.
The transformer is stateless (fit does nothing).
- class nirs4all.operators.transforms.features.ResampleTransformer(num_samples: int)[source]
Bases:
BaseEstimator,TransformerMixin