Skip to main content

interpret.datagrid()

Build a covariate grid as the cartesian product of supplied columns.

Usage

interpret.datagrid(
    data,
    **cols,
)

Columns not listed in cols are held constant: numeric columns use the column mean; non-numeric columns use the mode.

Parameters

data: IntoFrame

Reference data frame defining the available columns.

**cols: list[float] | list[int]
Column names mapped to lists of values to cross.

Returns

pd.DataFrame
One row per grid point.

Examples

Hold unspecified columns at their mean or mode::

grid = pathmc.datagrid(df, X=[0.0, 1.0], Z=[-1.0, 0.0, 1.0])
m.predictions("Y", newdata=grid)

See Also

datagrid()

Same helper bound to a fitted model.