augment()

Return an observation-level DataFrame for a fitted model.

Usage

Source

augment(
    model,
    data=None,
    **kwargs,
)

Produces one row per observation, appending model-derived columns (e.g., fitted values, residuals, or predicted survival probabilities) to the original data. This is the Python equivalent of R’s broom::augment().

Parameters

model: object

A fitted Greenwood estimator (e.g., CoxPH).

data: Any = None

The original data used to fit the model. Required by some adapters (e.g., Cox residuals need the covariate matrix); optional for others.

**kwargs: Any
Forwarded to the registered adapter. Common options include format=.

Returns

DataFrame
An observation-level summary with predictions or residuals.

Examples

Once an augment adapter is registered for a model class, call augment() to get observation-level predictions or residuals:

import greenwood as gw

lung = gw.load_dataset("lung", backend="polars")
y = gw.Surv.right(lung["time"], event=(lung["status"] == 2))
cox = gw.CoxPH().fit(y, covariates=lung[["age", "sex"]])
gw.augment(cox, data=lung, format="polars")