cleverly.interventions.RegimeSet#
- class cleverly.interventions.RegimeSet(names: tuple[str, ...], values: ndarray[tuple[Any, ...], dtype[float64]], reference: float = 0.0)[source]#
The regimes a fit targets, and their evaluated densities.
Keyed by an internal float code exactly as the arms are, with the labels carried alongside – the same convention, and for the same reason: every array that is per regime (the clever covariate’s columns, the counterfactual predictions, the influence curves) can then be handled by code that does not count regimes or know what they mean, while every reported name uses what the user called them.
- Parameters:
- Attributes:
- names:
Regime labels in code order, so
names[r]is the label of codefloat(r).- values:
(n, K, R)densities:values[i, a, r]is \(g^\star_r(a \mid W_i)\).- reference:
The regime code contrasts are taken against, defaulting to the first supplied.
Methods#
- RegimeSet.column(code: float) ndarray[tuple[Any, ...], dtype[float64]][source]#
Return one regime’s evaluated density.
- classmethod RegimeSet.evaluate(interventions: Sequence[Intervention], data: CausalData, *, reference: str | None = None) RegimeSet[source]#
Evaluate every intervention on
dataand assemble the set.- Parameters:
- interventionssequence
ofIntervention The regimes to evaluate, in the order their codes will follow.
- data
CausalData Validated study data to evaluate them on.
- reference
strorNone Label of the regime contrasts are taken against.
Noneuses the first one supplied, mirroring the arm convention where the reference is the lowest code.
- interventionssequence
- Returns:
RegimeSetThe evaluated densities, keyed by code.
Notes
It runs
refuse_regime_densities()on every intervention before it evaluates any density, so aRuleor a user-writtenInterventionmeets its declaration check as aStochasticdoes. A regime changed withobject.__setattr__can reach this method directly with a declaration this version refuses.
- RegimeSet.subset(index: Any) RegimeSet[source]#
The same regimes on a row subset – a bootstrap resample, a validation fold.
The densities are sliced rather than re-evaluated. For a regime that is a function of \(W\) alone the two agree exactly, and slicing is what keeps a loaded result (which carries the evaluated densities but not the callables that made them) usable everywhere a fitted one is.
- Parameters:
- indexarray_like
Row positions or a boolean mask.
- Returns:
RegimeSetThe same regimes over the selected rows.
Attributes#
- RegimeSet.codes#
Regime codes,
(0.0, ..., R-1.0), in the order the regimes were supplied.
- RegimeSet.is_static#
Whether every regime puts all its mass on one arm, the same one for every row.
The condition under which the regime path is estimating exactly what the arm path estimates, and so the one the equivalence test checks.
- RegimeSet.labels#
Code to label, which is what
parameter_name()is given.
- RegimeSet.n#
Return the number of observations.
- RegimeSet.n_arms#
Return the number of treatment arms.
- RegimeSet.n_regimes#
Return the number of regimens.