cleverly.TruncationCurve#
- class cleverly.TruncationCurve(frame: Any)[source]#
The estimate re-computed at other limits on the probabilities that weight it.
result.diagnostics.truncation_curve()returns one. It holds the frame the curve computes and reads like it: attribute access,[],lenand iteration go to the frame, socurve["psi"]andcurve.columnswork. Passto_frame()where a dataframe itself is needed, such asisinstanceor a frame comparison. Two curves compare by identity.- Parameters:
- frame
dataframe One row per limits pair and estimand. A point-treatment curve carries the estimate, its spread, the share of units capped and the fitted reference; a longitudinal curve carries the estimate, the fitted reference and the capped score-cell counts.
- frame
See also
cleverly.sensitivity.positivity.truncation_curveThe frame of a point-treatment fit.
cleverly.plotting.sensitivityThe plot
plot()draws.
Methods#
- TruncationCurve.plot(**kwargs: Any) Any[source]#
Plot the estimate against the probability limits, with the share of units capped.
- Parameters:
- **kwargs
Passed to
cleverly.plotting.sensitivity():estimand=,outcome_label=,units=andtitle=.
- Returns:
FigureTwo panels with a shared x axis.
Examples
>>> import matplotlib >>> matplotlib.use("Agg") >>> import matplotlib.pyplot as plt >>> from sklearn.linear_model import LinearRegression, LogisticRegression >>> from cleverly import ATE, CausalStudy, PointTreatment >>> from cleverly.datasets import make_linear_ate >>> frame, _ = make_linear_ate(n=200, seed=0) >>> study = CausalStudy( ... frame, ... design=PointTreatment( ... outcome="Y", treatment="A", adjustment=("W1", "W2", "W3", "W4") ... ), ... ) >>> result = study.identify(ATE()).estimate( ... outcome_learner=LinearRegression(), ... treatment_learner=LogisticRegression(max_iter=1000), ... cross_fit=False, ... random_state=0, ... ) >>> fig = result.diagnostics.truncation_curve().plot() >>> fig.axes[0].get_ylabel() 'Average effect' >>> plt.close(fig)
- TruncationCurve.summary(detail: Literal['short', 'full'] = 'short') Summary[source]#
Return the printed summary of the curve.
- Parameters:
- detail{“short”, “full”}
"short"prints one row per estimand and limits, with the change from the fitted estimate and how much the limits capped."full"adds every limits pair to six significant figures.
- Returns:
SummaryA
strwhose value is the printed text. Itsfacts,tables,notesandreadinghold the parts as data.