midlearn.plot_conditional
- midlearn.plot_conditional(conditional: MIDConditional, style: Literal['ice', 'centered'] = 'ice', theme: str | pt.color_theme | None = None, var_color: str | None = None, dots: bool = True, reference: int = 0, **kwargs)[source]
Visualize Individual Conditional Expectation (ICE) plots or Centered ICE (c-ICE) plots with plotnine. This is a porting function for the R function midr::ggmid.mid.conditional().
- Parameters:
conditional (MIDConditional) – A fitted
MIDConditional
object containing the ICE data.style ({'ice', 'centered'}, default 'ice') – The plotting style. ‘ice’ plots raw predicted values against the predictor variable. ‘centered’ displays the change in prediction relative to a reference point, by subtracting the prediction at the reference point for each individual observation.
theme (str or pt.color_theme or None, default None) – The color theme to use for the line colors.
var_color (str or None, default None) – The name of a column (from the original data) to map to the color aesthetic of the ICE lines. This helps visualize heterogeneity.
dots (bool, default True) – If True, plots points for the observed (original) predictions for each sample.
reference (int, default 0) – The 0-indexed sample point used as the reference prediction for centering when style=’centered’ is used.
**kwargs (dict) – Additional keyword arguments passed to the main layer of the plot.
- Returns:
A plotnine object representing the conditional expectation visualization.
- Return type:
plotnine.ggplot.ggplot