from greenwood.summaries import register_glance
# Define a glance adapter that returns model-level statistics
def _glance_my_model(model, *, format=None, **kwargs):
from greenwood._backends import to_dataframe
return to_dataframe({"n": [model.n_], "loglik": [model.loglik_]}, format=format)
# Register the adapter for the custom model class
register_glance("mypackage.MyModel", _glance_my_model)summaries.register_glance()
Register a glance adapter for a model class.
Usage
summaries.register_glance(
class_path,
fn,
)This is the extension point for adding glance() support to new estimator classes. Each adapter is a callable that accepts a fitted model and returns a one-row summary DataFrame with model-level statistics (e.g., log-likelihood, AIC, number of observations).
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, *, format=None, **kwargs) -> DataFrame.
Examples
Register a custom glance adapter: