midlearn.plot_importance
- midlearn.plot_importance(importance: MIDImportance, style: Literal['barplot', 'heatmap'] = 'barplot', theme: str | pt.color_theme | None = None, max_nterms: int | None = 30, **kwargs)[source]
Visualize the importance scores of the component functions from a fitted MID model with plotnine. This is a porting function for the R function midr::ggmid.mid.importance().
- Parameters:
importance (MIDImportance) – A fitted
MIDImportance
object containing the component importance scores.style ({'barplot', 'heatmap'}, default 'barplot') – The plotting style. ‘barplot’ displays importance as horizontal bars, suitable for a large number of terms. ‘heatmap’ displays importance in a matrix format, suitable for visualizing main effects and two-way interactions simultaneously.
theme (str or pt.color_theme or None, default None) – The color theme to use for the plot.
max_nterms (int or None, default 30) – The maximum number of terms to display when style=’barplot’. Terms are sorted by importance before truncation. If None, all terms are displayed.
**kwargs (dict) – Additional keyword arguments passed to the main layer of the plot.
- Returns:
A plotnine object representing the visualization of component importance.
- Return type:
plotnine.ggplot.ggplot