cleverly.interventions.LearnedRuleRecord#

class cleverly.interventions.LearnedRuleRecord(name: str, fold_sizes: tuple[int, ...], fold_estimates: tuple[float, ...], treated_shares: tuple[float, ...], blip_quantiles: tuple[tuple[float, ...], ...])[source]#

Record what a learned-rule fit estimated, under result.extra["learned_rule"].

The fitted fold models are not kept. The realized rule of each row is result.nuisance.regimes.values[:, 1, 0], and the folds, the learner templates and the seeds replay the fit.

Parameters:
namestr

The label of the rule.

fold_sizestuple of int

The validation rows of each outer fold.

fold_estimatestuple of float

The targeted plug-in value of each fold on its own validation rows.

treated_sharestuple of float

The share of each fold’s validation rows that its rule assigns to the higher arm code.

blip_quantilestuple of tuple of float

For each fold, quantiles of the estimated blip Qbar_v(1, W) - Qbar_v(0, W) on its validation rows, at quantile_levels, on the scale the outcome regression is fitted on.

Attributes:
n_foldsint

Return the number of outer folds.

fold_weightstuple of float

Return the weight of each fold in the reported average, 1/V for every fold.

rulestr

Return the rule class, in words (RULE_CLASS).

targetstr

Return what the reported value is (TARGET_KIND).

quantile_levelstuple of float

Return the levels of blip_quantiles (BLIP_QUANTILE_LEVELS).

Methods#

LearnedRuleRecord.describe() → str[source]#

Return the line that summary() prints for this fit.

Returns:
str

The target, the fold count, the source of the definition, and the range of the treated share over the folds.

Attributes#

LearnedRuleRecord.fold_weights#

Return the weight of each fold in the reported average, 1/V for every fold.

LearnedRuleRecord.n_folds#

Return the number of outer folds.

LearnedRuleRecord.quantile_levels#

Return the levels of blip_quantiles (BLIP_QUANTILE_LEVELS).

LearnedRuleRecord.rule#

Return the rule class, in words (RULE_CLASS).

LearnedRuleRecord.target#

Return what the reported value is (TARGET_KIND).

LearnedRuleRecord.name: str#
LearnedRuleRecord.fold_sizes: tuple[int, ...]#
LearnedRuleRecord.fold_estimates: tuple[float, ...]#
LearnedRuleRecord.treated_shares: tuple[float, ...]#
LearnedRuleRecord.blip_quantiles: tuple[tuple[float, ...], ...]#