SubjectPreprocessingChain
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class SubjectPreprocessingChain(methods: Sequence[Any])[source]
Bases:
objectStateless preprocessing of one subject’s feature matrix.
Applies its methods using statistics computed from the matrix it is given, discarding them afterwards. That is exactly what individual-level preprocessing means, and it is why this chain needs no train/predict distinction: an external validation subject is normalised by its own distribution, never by the training cohort’s.
The same instance can preprocess voxel features and supervoxel features, because neither the methods nor this chain inspect what a row represents.
- Parameters:
methods – Ordered methods to apply. Must be non-empty. Imputation is prepended when not named explicitly.
- set_random_state(seed: int) None[source]
Seed every stochastic method in the chain.
- Parameters:
seed – Seed forwarded to methods exposing
set_random_state.
- __call__(block: DataFrame) DataFrame[source]
Preprocess one matrix, fitting and discarding state per call.
- Parameters:
block – Unit-by-feature matrix (rows = voxels or supervoxels).
- Returns:
The preprocessed matrix, row-aligned and row-count preserving. Column count may shrink when a filtering method is present.
- Raises:
HABITAPIError – If a method produces non-finite values.