Welcome to PyCEbox’s documentation!¶
PyCEbox API¶

pycebox.ice.
ice
(data, column, predict, num_grid_points=None)[source]¶ Generate individual conditional expectation (ICE) curves for a model.
Parameters:  data (
pandas
DataFrame
) – the sample data from which to generate ICE curves  column (
str
) – the name of the column indata
that will be varied to generate ICE curves  predict (callable) – the function that generates predictions from the model.
Must accept a
DataFrame
with the same columns asdata
.  num_grid_points (
None
orint
) –the number of grid points to use for the independent variable of the ICE curves. The independent variable values for the curves will be quantiles of the data.
If
None
, the values of the independent variable will be the unique values ofdata[column]
.
Returns: A
DataFrame
whose columns are ICE curves. The row index is the independent variable, and the column index is the original data point corresponding to that ICE curve.Return type: pandas
DataFrame
 data (

pycebox.ice.
ice_plot
(ice_data, frac_to_plot=1.0, plot_points=False, point_kwargs=None, x_quantile=False, plot_pdp=False, centered=False, centered_quantile=0.0, color_by=None, cmap=None, ax=None, pdp_kwargs=None, **kwargs)[source]¶ Plot the ICE curves
Parameters:  ice_data (
pandas
DataFrame
) – the ICE data generated bypycebox.ice.ice()
 frac_to_plot (
float
) – the fraction of ICE curves to plot. If less than one, randomly samples columns ofice_data
to plot.  plot_points (
bool
) – whether or not to plot the original data points on the ICE curves. In this case,point_kwargs
is passed as keyword arguments to plot.  x_quantile (
bool
) – ifTrue
, the plotted xcoordinates are the quantiles ofice_data.index
 plot_pdp – if
True
, plot the partial depdendence plot. In this case,pdp_kwargs
is passed as keyword arguments toplot
.  centered (
bool
) – ifTrue
, each ICE curve is centered to zero at the percentile closest tocentered_quantile
.  color_by (
None
,str
, or callable) –If a string, color the ICE curve by that level of the column index.
If callable, color the ICE curve by its return value when applied to a
DataFrame
of the column index ofice_data
 cmap (
matplotlib
Colormap
) –  ax (
None
ormatplotlib
Axes
) – theAxes
on which to plot the ICE curves
Other keyword arguments are passed to
plot
 ice_data (

pycebox.ice.
pdp
(ice_data)[source]¶ Calculate a partial dependence plot from ICE data
Parameters: ice_data ( pandas
DataFrame
) – the ICE data generated bypycebox.ice.ice()
Returns: the partial dependence plot curve Return type: pandas
Series