cleverly.targeting_curves.TargetingCurve#

class cleverly.targeting_curves.TargetingCurve(score: str, compare: str | None, route: str, n_train: int | None, n_eval: int, grid: tuple[float, ...], estimates: dict[str, list[~typing.Any]], ate: float, critical_value: float, n_half_samples: int, alpha: float, status: str, status_reason: str, backend: str | None = None, span: dict[str, float] = <factory>, evaluation: ~cleverly.targeting_curves.TargetingEvaluation | None = None, fit: ~typing.Any = None, score_curve: ~typing.Any = None)[source]#

How much treating by a priority score first gains over treating at random.

Parameters:
scorestr

The ranked score’s name.

comparestr or None

The second score of a paired comparison, or None.

route{“external”, “split”}

"external": a study column fitted on other rows. "split": a curve refitted on a declared training split and evaluated on the other rows.

n_trainint or None

Rows of the training part on the split route; None on the external route.

n_evalint

Evaluation rows.

gridtuple of float

The treated fractions.

estimatesdict of str to list

One entry per column of COLUMNS, one row per estimate: the TOC and the gain at each grid point, the group effects, the AUTOC and the Qini, for each score and, with a comparison, their differences under the name "<score> - <compare>".

atefloat

The average effect, read from the fluctuation’s own constant column, so that each TOC equals its top-fraction mean minus this value exactly.

critical_valuefloat

The sup-t critical value of the band over the grid points below 1, or nan when the band is withheld.

n_half_samplesint

Half-sample draws.

alphafloat

Intervals hold at 1 - alpha; the band jointly.

status{“supported”, “experimental”}

The worst status of the rows.

status_reasonstr

Every reason that applies, or the empty string.

backendstr or None

The dataframe backend of the study’s data.

spandict of str to float

The fluctuation’s basis: columns (weight columns), rank (basis directions), out_of_span (the largest relative component of a column outside the basis) and score_norm (the largest score equation after targeting).

evaluationTargetingEvaluation

The evaluation rows the draws read.

fitTMLEResult

The ATE fit on the evaluation rows whose nuisances the curve targets.

score_curveEffectCurveResult or None

On the split route, the curve refit on the training rows whose predictions are the score; None on the external route.

Methods#

TargetingCurve.area(quantity: str = 'autoc', score: str | None = None) → dict[str, Any][source]#

The row of one area.

Parameters:
quantity{“autoc”, “qini”}

The area.

scorestr or None

As rows().

Returns:
dict

The row, keyed by COLUMNS.

TargetingCurve.plot(view: str = 'toc', **kwargs: Any) → Any[source]#

Draw the curve with cleverly.plotting.targeting().

Parameters:
view{“toc”, “gain”, “difference”}

Which view to draw.

**kwargsAny

Passed to cleverly.plotting.targeting().

Returns:
Figure

The figure drawn on.

TargetingCurve.rows(quantity: str, score: str | None = None) → list[dict[str, Any]][source]#

The rows of one quantity of one score, in grid order.

Parameters:
quantity{“toc”, “gain”, “group_effect”, “autoc”, “qini”}

The quantity.

scorestr or None

The score’s name, or "<score> - <compare>"; the primary score when omitted.

Returns:
list of dict

One mapping per row, keyed by COLUMNS.

TargetingCurve.summary(*, detail: Literal['short', 'full'] = 'short') → Any[source]#

A printable report of the curve.

Parameters:
detail{“short”, “full”}

"full" adds the gain, the group effects, the differences and the p-values.

Returns:
Summary

The report.

TargetingCurve.to_frame() → Any[source]#

The estimates, one row each, in the study’s backend.

Returns:
dataframe

The columns of COLUMNS.

Attributes#

TargetingCurve.backend: str | None = None#
TargetingCurve.evaluation: TargetingEvaluation | None = None#
TargetingCurve.fit: Any = None#
TargetingCurve.score_curve: Any = None#
TargetingCurve.score: str#
TargetingCurve.compare: str | None#
TargetingCurve.route: str#
TargetingCurve.n_train: int | None#
TargetingCurve.n_eval: int#
TargetingCurve.grid: tuple[float, ...]#
TargetingCurve.estimates: dict[str, list[Any]]#
TargetingCurve.ate: float#
TargetingCurve.critical_value: float#
TargetingCurve.n_half_samples: int#
TargetingCurve.alpha: float#
TargetingCurve.status: str#
TargetingCurve.status_reason: str#
TargetingCurve.span: dict[str, float]#