PooledUnits

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 PooledUnits(frame: DataFrame, subject_ids: Tuple[str, ...], boundaries: Tuple[Tuple[int, int], ...])[source]

Bases: object

The fan-in product: one cohort matrix plus its subject index.

frame

Pooled unit-by-feature matrix with a positional index, in cohort order. Stored (rather than derived) so cohort-level consumers see the exact frame the per-subject units provided, dtypes included.

Type:

pandas.core.frame.DataFrame

subject_ids

Owning subject id per row block, in cohort order.

Type:

Tuple[str, …]

boundaries

(start, stop) row range of each subject’s block inside frame; subject_ids[i] owns frame.iloc[start:stop].

Type:

Tuple[Tuple[int, int], …]

property matrix: ndarray

Return the pooled matrix as a float64 array, rows in cohort order.

property feature_names: Tuple[str, ...]

Return the pooled feature columns in order.

fan_out(values: ndarray) → Dict[str, ndarray][source]

Split a cohort-length vector back into per-subject pieces.

This is the numerical core of the fan-out movement: any quantity computed row-wise on the pooled matrix (cluster labels, distances, quality scores) returns to its subjects through the same index the fan-in recorded.

Parameters:

values – Array whose first axis has one entry per pooled row.

Returns:

Mapping of subject id to that subject’s slice of values, in cohort order.

Raises:

HABITAPIError – If values does not have one entry per row.

__init__(frame: DataFrame, subject_ids: Tuple[str, ...], boundaries: Tuple[Tuple[int, int], ...]) → None