summaries.register_augment()

Register an augment adapter for a model class.

Usage

Source

summaries.register_augment(
    class_path,
    fn,
)

This is the extension point for adding augment() support to new estimator classes. Each adapter is a callable that accepts a fitted model and (optionally) the original data, and returns an observation-level DataFrame with per-row predictions or residuals appended.

Parameters

class_path: str

Fully qualified class name used as the registry key, e.g., "greenwood._cox.CoxPH".

fn: Tidier
Callable with signature fn(model, data=None, *, format=None, **kwargs) -> DataFrame.

Examples

Register a custom augment adapter:

from greenwood.summaries import register_augment

# Define an augment adapter that appends per-row predictions
def _augment_my_model(model, data=None, *, format=None, **kwargs):
    from greenwood._backends import to_dataframe

    preds = model.predict(data)
    return to_dataframe({"prediction": preds}, format=format)

# Register the adapter for the custom model class
register_augment("mypackage.MyModel", _augment_my_model)