CohortFeaturePreprocessor
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 CohortFeaturePreprocessor(*args, **kwargs)[source]
Bases:
ProtocolPreprocess the pooled cohort feature matrix with fitted statistics.
Stateful by construction, and the mirror image of
SubjectFeaturePreprocessor: its purpose is to place units from DIFFERENT subjects in one comparable feature space, so the clusters that define habitats mean the same thing for everyone. That requires shared statistics, which requires fitting, which makes this the single leakage-sensitive step of habitat definition –fitmust see training data only.The fitted state therefore belongs in the published
HabitatModel: a habitat definition applied to a new cohort without its cohort-level preprocessing would put that cohort in a different feature space while appearing to work.- fit(block: DataFrame) CohortFeaturePreprocessor[source]
Learn the transformation from the pooled TRAINING matrix.
- Parameters:
block – Rows are clustering units from every training subject.
- Returns:
self, fitted.
- transform(block: DataFrame) DataFrame[source]
Apply the fitted transformation to a pooled matrix.
- Parameters:
block – Matrix carrying the feature columns seen at fit time.
- Returns:
The preprocessed matrix, rows preserved.
- __init__(*args, **kwargs)