HabitatPrototypeAlignment
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 HabitatPrototypeAlignment(habitat_maps: Tuple[HabitatMap, ...], prototypes: ndarray, feature_names: Tuple[str, ...], source: str, assignments: DataFrame, objective: float, n_iter: int, converged: bool, seed_subject_id: str, metric: str, standardize: str, reduction: str, location: ndarray | None, scale: ndarray | None, match_prototypes: ndarray, model_id: str)[source]
Bases:
objectCohort habitat maps renamed onto shared prototypes.
Returned by
align_habitat_maps_to_prototypes().Pass it back as
prototypes=to name new subjects with the same definition (same prototypes, same scaler, same metric, samemodel_id).- habitat_maps
Aligned maps, input order. Prototype
kis habitat idk + 1in every map, so the same id means the same habitat across subjects. No subject loses or merges a habitat. A habitat stays unnamed only whenmax_distanceis set (or when a subject has more habitats than frozen prototypes); it then keeps a subject-local id aboveKthat is not comparable across subjects.- Type:
Tuple[habit.contracts.habitat.HabitatMap, …]
- prototypes
Shape
(K, n_features)in the units of the input summaries (rowkis habitat idk + 1): the mean (median formetric="manhattan") of every subject summary assigned to that prototype. Descriptive; matching usesmatch_prototypes. For frozen runs these are the reference’s.- Type:
- feature_names
Column names of
prototypes: the models’ or feature fields’ names when available, elsef0, f1, ....- Type:
Tuple[str, …]
- source
Where the habitat summaries came from:
"models"(fitted clustering centroids),"features"(per-habitat means of a supplied voxel feature volume / field), or"centroids"(caller-supplied matrices).- Type:
- assignments
One row per input habitat with columns
subject_id,habitat_id(original id),prototype_id(new id, NA when left unnamed), anddistanceto the prototype in the matching space (seemetric).- Type:
pandas.core.frame.DataFrame
- objective
Sum of matched metric costs plus the unmatched penalty, in the matching space.
- Type:
- location
Column means of the z-score (
Nonewithout z-score).- Type:
numpy.ndarray | None
- scale
Column standard deviations of the z-score, or
None.- Type:
numpy.ndarray | None
- match_prototypes
Prototypes in the matching space (after z-score; unit rows for cosine / correlation). Reused by frozen runs.
- Type:
- __init__(habitat_maps: Tuple[HabitatMap, ...], prototypes: ndarray, feature_names: Tuple[str, ...], source: str, assignments: DataFrame, objective: float, n_iter: int, converged: bool, seed_subject_id: str, metric: str, standardize: str, reduction: str, location: ndarray | None, scale: ndarray | None, match_prototypes: ndarray, model_id: str) None