SurvivalOutcome

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 SurvivalOutcome(time_column: str, event_column: str, event_value: Any = 1)[source]

Bases: object

Right-censored time-to-event endpoint, e.g. overall or progression-free survival.

The two columns are declared TOGETHER because neither is interpretable alone: a follow-up time without an event indicator cannot distinguish a death at 10 months from a patient still alive at last contact, and every survival estimator, metric and plot needs both.

time_column

Follow-up duration until the event or until censoring. Units are the study’s own (months, days); HABIT never converts them, it only requires that they be consistent within a table.

Type:

str

event_column

Event indicator. Rows where it equals event_value experienced the event; all others are treated as right-censored.

Type:

str

event_value

Value in event_column denoting an observed event. Explicit because both 1/0 and "Dead"/"Alive" codings are common in clinical tables, and guessing wrong inverts the entire analysis.

Type:

Any

__post_init__() → None[source]

Validate the column names and that they are distinct.

property columns: Tuple[str, ...]

Return the time and event columns, in that order.

times(frame: DataFrame) → Series[source]

Return the follow-up durations.

Parameters:

frame – Frame carrying time_column.

Returns:

The follow-up durations aligned to frame.

event_mask(frame: DataFrame) → Series[source]

Return a boolean mask marking rows with an OBSERVED event.

Parameters:

frame – Frame carrying event_column.

Returns:

Boolean Series aligned to frame, true where the event was observed and false where the row is right-censored.

__init__(time_column: str, event_column: str, event_value: Any = 1) → None