modelsight.calibration

Submodules

Package Contents

Functions

hosmer_lemeshow_plot(, annotate_bars, title, ...)

Plot observed vs. predicted probabilities (can be risks in case of survival models), groups by

modelsight.calibration.hosmer_lemeshow_plot(y_true: modelsight._typing.ArrayLike, y_pred: modelsight._typing.ArrayLike, n_bins: int = 10, colors: Tuple[str, str] = ('blue', 'red'), annotate_bars: bool = True, title: str = '', brier_score_annot: str = '', ax: matplotlib.pyplot.Axes = None, **kwargs) Tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes][source]

Plot observed vs. predicted probabilities (can be risks in case of survival models), groups by n-tiles of predicted probabilities.

Parameters:
  • y_true (ArrayLike) – (n_obs,) shaped array of ground-truth values

  • y_pred (ArrayLike) – (n_obs,) shaped array of predicted probabilities

  • n_bins (int) – Number of bins to group observed and predicted probabilities into

  • colors (Tuple[str, str]) – Pair of colors for observed (line) and predicted (vertical bars) probabilities.

  • annotate_bars (bool) – Whether bars should be annotated with the number of observed probabilities in each bin.

  • title (str) – Title to display on top of the calibration plot.

  • brier_score_annot (str) – Optional brier score (95% CI) annotation on the top-left corner.

  • ax (plt.Axes) – A matplotlib Axes object to draw the calibration plot into. If None, an Axes object is created by default.

Returns:

f, ax – f: pyplot figure ax: pyplot Axes

Return type:

Tuple[plt.Figure, plt.Axes]