cleverly.longitudinal.LearnedRegimenNode#

class cleverly.longitudinal.LearnedRegimenNode(node: int, treatment: str, arms: tuple[str, str], treated_shares: tuple[float, ...], gap_quantiles: tuple[tuple[float, ...], ...], rule_disagreement: float)[source]#

Record one decision node of a learned regimen: what its fold rules did.

Parameters:
nodeint

The decision node, counted from one.

treatmentstr

The node’s treatment column.

armstuple of str

The node’s two treatment levels in arm-code order; the rule treats with the second.

treated_sharestuple of float

For each fold, the share of its validation rows at risk at this node under the fold’s own rule pair that the fold’s rule treats. At the first node every row is at risk.

gap_quantilestuple of tuple of float

For each fold, quantiles of the absolute blip behind the rule on the same rows, at LEARNED_REGIMEN_QUANTILE_LEVELS, on the scale the regressions are fitted on. Mass near 0 speaks against the margin condition of a fixed rule limit.

rule_disagreementfloat

The share of rows at which the fold rules do not all assign the same arm, read from every fold’s rule on every row (at the second node, on the rows uncensored after the first node). At the second node a fold’s code is the second rule of the first-node arm that fold chose, so the share also counts rows whose folds chose different first-node arms. Rules that settle to one limit agree almost everywhere.

Methods#

Attributes#

LearnedRegimenNode.node: int#
LearnedRegimenNode.treatment: str#
LearnedRegimenNode.arms: tuple[str, str]#
LearnedRegimenNode.treated_shares: tuple[float, ...]#
LearnedRegimenNode.gap_quantiles: tuple[tuple[float, ...], ...]#
LearnedRegimenNode.rule_disagreement: float#