cleverly.longitudinal.SurvivalSelection#

class cleverly.longitudinal.SurvivalSelection(arm: str, horizon: int, moves: tuple[tuple[str, str] | None, ...], g1_terms: tuple[tuple[str, ...], ...], g2_terms: tuple[tuple[str, ...], ...], n_steps: tuple[int, ...], train_loss: NDArray[float64], train_penalty: NDArray[float64], train_risk: NDArray[float64], cv_risk: NDArray[float64], converged: tuple[bool, ...], clipped: tuple[int, ...], dropped_terms: tuple[int, ...], selected: int, penalized: bool, folds: Folds, covariates: tuple[str, ...], diagnostic_horizon: int, fold_held_nodes: tuple[tuple[int, int, str], ...] = (), target_solves: tuple[int, ...] = (), candidate_pairs: tuple[int, ...] = (), penalty_form: str = 'printed_24', combination: str = 'sum_loss_plus_penalty')[source]#

The collaborative selection of one arm at one horizon.

Parameters:
armstr

The regimen label.

horizonint

The horizon, counted from one.

movestuple

The move of each path position: None at \(M_0\), then ("g1", term) or ("g2", term).

g1_termstuple of tuple of str

The treatment-model covariates at each position.

g2_termstuple of tuple of str

The censoring-model terms at each position, beside the node indicators.

n_stepstuple of int

The restarts the search had made when it reached each position.

train_lossFloatArray

The selection loss of each position on the full data.

train_penaltyFloatArray

The penalty (24) of each position on the full data, zero without a penalty.

train_riskFloatArray

Their sum.

cv_riskFloatArray

The cross-validated penalized risk of each move count, summed over the folds. It chooses selected.

convergedtuple of bool

Whether each position’s targeting solve converged on the full data.

clippedtuple of int

The person-nodes whose hazard the loss clip moved at each position.

dropped_termstuple of int

The terms each position’s two fits aliased with earlier columns.

selectedint

The position the cross-validated risk chose, the first of ties.

penalizedbool

Whether the risk adds the penalty.

penalty_formstr

"printed_24": the printed (24) of the source, not the influence-curve variance.

combinationstr

"sum_loss_plus_penalty": the loss summed over the scored rows plus the penalty.

foldsFolds

The realized selection split, with its origin.

fold_held_nodestuple of tuple

(fold, node, kind) of each censoring node a selection fold held rather than fitted: "no_censoring" at retention one, "all_censored" at retention 1e-12.

covariatestuple of str

The baseline covariates the search drew from, in data order.

diagnostic_horizonint

The horizon whose selections result.mechanism reports.

target_solvestuple of int

The hazard targeting solves of the search: the full-data path first, then each selection fold’s path. One per scored candidate position, so it counts the work the greedy search did, restarts included.

candidate_pairstuple of int

The distinct candidate pairs of mechanisms each of those paths targeted. Regimens on one arm share its search and report the same counts.

Methods#

SurvivalSelection.summary(*, detail: Detail = 'short') → Summary[source]#

A printable report of the selection path.

Parameters:
detail{“short”, “full”}, default “short”

Accepted for symmetry with the other records; both print the same.

Returns:
Summary

The path, one row per position, and the chosen position.

SurvivalSelection.to_frame(data: LongitudinalData | None = None) → Any[source]#

One row per path position.

Parameters:
dataLongitudinalData or None

When given, the rows come back in that data’s frame type.

Returns:
dict or frame

The columns position, move, g1_terms, g2_terms, n_steps, train_loss, train_penalty, train_risk, cv_risk, converged, clipped, dropped_terms and selected.

Attributes#

SurvivalSelection.candidate_pairs: tuple[int, ...] = ()#
SurvivalSelection.combination: str = 'sum_loss_plus_penalty'#
SurvivalSelection.fold_held_nodes: tuple[tuple[int, int, str], ...] = ()#
SurvivalSelection.move_labels#

The move of each path position in words: "M0", then "+<term> in <g1|g2>".

SurvivalSelection.penalty_form: str = 'printed_24'#
SurvivalSelection.selected_terms#

The treatment-model covariates and the censoring-model terms of the selected position.

SurvivalSelection.target_solves: tuple[int, ...] = ()#
SurvivalSelection.arm: str#
SurvivalSelection.horizon: int#
SurvivalSelection.moves: tuple[tuple[str, str] | None, ...]#
SurvivalSelection.g1_terms: tuple[tuple[str, ...], ...]#
SurvivalSelection.g2_terms: tuple[tuple[str, ...], ...]#
SurvivalSelection.n_steps: tuple[int, ...]#
SurvivalSelection.train_loss: NDArray[float64]#
SurvivalSelection.train_penalty: NDArray[float64]#
SurvivalSelection.train_risk: NDArray[float64]#
SurvivalSelection.cv_risk: NDArray[float64]#
SurvivalSelection.converged: tuple[bool, ...]#
SurvivalSelection.clipped: tuple[int, ...]#
SurvivalSelection.dropped_terms: tuple[int, ...]#
SurvivalSelection.selected: int#
SurvivalSelection.penalized: bool#
SurvivalSelection.folds: Folds#
SurvivalSelection.covariates: tuple[str, ...]#
SurvivalSelection.diagnostic_horizon: int#