cleverly.validation.ScoreCheck#
- class cleverly.validation.ScoreCheck(rows: tuple[ScoreCheckRow, ...], tolerance: float, n: int, corrected: bool = False, corrections: CorrectionCheck | None = None, backend: str | None = None, inference: Literal['influence_curve', 'working_mechanism_plugin', 'generated_design_plugin', 'estimated_weight_plugin', 'adaptive_baseline_plugin', 'no_cluster_variance_plugin', 'few_cluster_plugin', 'constant_node_plugin', 'stack_failure_plugin'] = 'influence_curve', stopping: str = 'relative', alpha_sig: float = 0.05)[source]#
Whether the targeting step solved the score equations it was supposed to.
“The efficient score equation” for a plain fit, and deliberately not that phrase for a doubly-robust one – see
corrected.- Parameters:
- rows
tupleofScoreCheckRow One row per estimand or targeted family.
- tolerance
float Score magnitude, in standard errors, a row may reach and pass.
- n
int Number of observations.
- correctedbool
Whether the fit carried DR-TMLE correction equations.
- corrections
CorrectionCheckorNone Those equations’ own check, when it did.
- backend
strorNone Dataframe backend
to_frame()returns whendatais omitted.- inference
str Inference status of the checked fit. One of
InferenceStatus, which the inference reference lists. A failing verdict names the spread the fit reports by it, so a fit that supplies no inference reads “plug-in standard errors”.- stopping
str The stopping rule the fit declared,
"relative"for the shipped one.- alpha_sig
float The significance level of the fit’s intervals.
- rows
Methods#
- ScoreCheck.one_line() str[source]#
The verdict as a block a report can append, without the table.
Phrased here rather than at the call site so that every place a verdict is spoken – this module’s own report, and
cleverly.TMLEResult.summary()– says the same thing. It names the failing rows, because “the check failed” without them sends the reader back to the method call this line exists to spare them.- Returns:
strThe verdict alone, for a report to append without the table.
- ScoreCheck.raise_if_failed() None[source]#
Raise when the check failed – for use in pipelines that must not ship a bad fit.
- ScoreCheck.rule_failure_line() str[source]#
The pinned line when the targeting did not meet the rule, else
"".- Returns:
strThe line
RULE_FAILURE_LINEofcleverly.fluctuation._score. Its detail names each equation that missed its rule and how many times its threshold its largest score is. An empty string means the targeting met the rule, or the fit declared none.
- ScoreCheck.rule_line() str[source]#
The pinned line of a fit under a declared rule, or
""under the shipped one.- Returns:
strThe largest score residual in standard errors, the estimand it is on, and the coverage a Wald interval keeps at that residual (
RESIDUAL_LINE).
Attributes#
- ScoreCheck.alpha_sig: float = 0.05#
The significance level of the fit’s intervals, which the coverage bound reads.
- ScoreCheck.backend: str | None = None#
Name of the dataframe backend the fit’s data arrived in, so that
to_frame()honours “results come back in the backend you passed in” without a caller having to thread the container back in by hand.
- ScoreCheck.corrected: bool = False#
Whether this fit reports the corrected curve \(D = D^* - D^*_Q - D^*_g\) – or the one term of it a single guard solves for, which
_curve()derives from the rows – rather than \(D^*\). True for aDRTMLEfit with a non-empty guard, and what the verdict branches on: the equations such a fit solves are its own three, and the curve they leave is the estimator’s influence function at the nuisance limits, which is generally not the efficient one. Signing that off as “the estimated efficient score equation” was the one place the package asserted the thingreduced_corrections()exists to deny.
- ScoreCheck.corrections: CorrectionCheck | None = None#
The per-arm corrections behind this check’s
identityandcorrectionrows, for a reader who wants the recomputation itself rather than the verdict on it.Noneon a check built by hand; empty rows on any fit that reports no corrections, which is every fit but a guardedDRTMLEone.
- ScoreCheck.declared#
Whether the fit declared a stopping rule other than the shipped one.
- ScoreCheck.failures#
Return rows that failed their check.
- ScoreCheck.identity_failures#
Failures that are software defects rather than unsolved equations.
A row here says the score the targeting step recorded and the term the reported curve carries are not the same functional of the state the fit returned – the DR-TMLE correction identity. Iterating longer cannot fix one, which is why it is worded apart from every other failure this class reports.
- ScoreCheck.inference: Literal['influence_curve', 'working_mechanism_plugin', 'generated_design_plugin', 'estimated_weight_plugin', 'adaptive_baseline_plugin', 'no_cluster_variance_plugin', 'few_cluster_plugin', 'constant_node_plugin', 'stack_failure_plugin'] = 'influence_curve'#
A default, so a check built by hand reads as the ordinary fit it describes.
- ScoreCheck.passed#
True when every row is within tolerance.
- ScoreCheck.rule_failures#
The failing rows that a declared rule judged, which are the rule not being met.
- ScoreCheck.stopping: str = 'relative'#
The stopping rule the fit declared,
"relative"for the shipped one. Under a declared rule the fluctuation rows are held to the rule’s thresholds and the estimand rows are diagnostics.
- ScoreCheck.rows: tuple[ScoreCheckRow, ...]#