cleverly.longitudinal.LearnedRegimenRecord#

class cleverly.longitudinal.LearnedRegimenRecord(label: str, seed: int | None, fold_sizes: tuple[int, ...], nodes: tuple[LearnedRegimenNode, ...], fold_rules: ndarray, fold_blips: ndarray)[source]#

Record what a learned-regimen fit estimated, under result.learned_regimen.

The fitted fold models are not kept. Each fold’s rule pair on every row is, so a refit of a fold’s rules can be checked against it, and the stitched assignment each row followed is result.fits[...].assignment.

Parameters:
labelstr

The label of the regimen.

seedint or None

The seed of the split and the learners, as result.repeats[0].seed records it.

fold_sizestuple of int

The validation rows of each outer fold.

nodestuple of LearnedRegimenNode

One record per decision node, in time order.

fold_rulesnumpy.ndarray

The (V, n, 2) arm codes of every fold’s rule pair on every row, as LearnedRules.assignments holds them.

fold_blipsnumpy.ndarray

The (V, n, 2) blips behind them, as LearnedRules.blips holds them.

Attributes:
n_foldsint

Return the number of outer folds.

fold_weightstuple of float

Return each fold’s weight n_v / n in the target and the estimate.

targetstr

Return what the reported value is (LEARNED_REGIMEN_TARGET).

quantile_levelstuple of float

Return the levels of each node’s gap quantiles.

Methods#

LearnedRegimenRecord.describe() → str[source]#

Return the line that a summary prints for this fit.

Returns:
str

The target, the fold count, how the rules are learned, the range of each node’s treated share over the folds, and the share of rows on which the fold rules disagree.

Attributes#

LearnedRegimenRecord.fold_weights#

Return each fold’s weight n_v / n in the target and the estimate.

LearnedRegimenRecord.n_folds#

Return the number of outer folds.

LearnedRegimenRecord.quantile_levels#

Return the levels of each node’s gap quantiles.

LearnedRegimenRecord.target#

Return what the reported value is (LEARNED_REGIMEN_TARGET).

LearnedRegimenRecord.label: str#
LearnedRegimenRecord.seed: int | None#
LearnedRegimenRecord.fold_sizes: tuple[int, ...]#
LearnedRegimenRecord.nodes: tuple[LearnedRegimenNode, ...]#
LearnedRegimenRecord.fold_rules: ndarray#
LearnedRegimenRecord.fold_blips: ndarray#