cleverly.datasets.learned_rule_truth#
- cleverly.datasets.learned_rule_truth(result: Any, outcome_learner: Any) float[source]#
Return the true value of the rules that a learned-rule fit of these data used.
A
LearnedRuleValuefit learns one rule in each fold, from the outcome model fitted on the other folds, and reports a weighted average of the values of those rules. The fold-evaluated report weights each fold by1/V, and the stacked report weights it by its share of the rows. This function refitsoutcome_learneron each fold’s training rows, checks that its rule matches the fit’s rule on every row of the fold, and averages the exact values of the refitted rules with the fit’s own fold weights. An in-sample fit (cross_fit=False) learns one rule on every row, and its target is the value of that one rule, which this function refits on every row.- Parameters:
- result
EstimationResult A
LearnedRuleValuefit of amake_treatment_rules()draw, adjusted forneedandlives_alonein that order.- outcome_learner
estimator The outcome learner of the fit. It must be deterministic, so that a refit reproduces the fitted model.
- result
- Returns:
floatThe average over the folds of
treatment_rule_value()of each fold’s rule, with the weightsresult.extra["learned_rule"].splits[0].fold_weights.
- Raises:
ValueErrorWhen the fit is not an unweighted
LearnedRuleValuefit ofhome_30onofferwith one split, adjusted forneedandlives_alone, or a refitted rule differs from the fit’s rule on a row.
See also
cleverly.LearnedRuleValueThe estimand of the fit.