FeatureTable
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 FeatureTable(frame: DataFrame, id_columns: Tuple[str, ...], feature_columns: Tuple[str, ...], outcome: Outcome | None = None, provenance: Provenance | None = None)[source]
Bases:
objectFeature table with explicit column semantics.
- frame
The underlying table.
- Type:
pandas.core.frame.DataFrame
- outcome
Declared study endpoint when present – a
BinaryOutcome,MulticlassOutcome,ContinuousOutcomeorSurvivalOutcome. An OBJECT rather than a column name because a survival endpoint occupies two columns, and because a name alone cannot tell a downstream metric whether the endpoint is a class or a quantity.- Type:
- provenance
How this table was produced.
- Type:
- property outcome_column: str | None
Return the endpoint’s single column, for one-column endpoints only.
Convenience for the binary / multiclass / continuous cases, whose endpoint really is one column. It deliberately RAISES for survival rather than returning the time column: silently answering with half of a two-column endpoint would let a caller written for classification train on follow-up time as if it were a label.
- Returns:
The endpoint column, or
Nonewhen the table declares no endpoint.- Raises:
HABITAPIError – If the endpoint spans multiple columns.
- feature_matrix() DataFrame[source]
Return only the model-input columns, indexed by the id columns.
Named
feature_matrixrather thanfeaturesso it cannot be confused with running feature extraction, and because it returns a matrix-like frame rather than a list of features.- Returns:
A frame with the id columns as (possibly multi-) index and only the declared feature columns as data.
- join(other: FeatureTable) FeatureTable[source]
Join another table on the shared id columns.
- Parameters:
other – Table to merge; must share
id_columns.- Returns:
A new table whose provenance records both inputs.
- Raises:
HABITAPIError – If the id columns do not match.