code: def plot_calibration(model, partition):
      r"""Display scikit-learn calibration plots.
  
      Parameters
      ----------
      model : alphapy.Model
          The model object with plotting specifications.
      partition : alphapy.Partition
          Reference to the dataset.
  
      Returns
      -------
      None : None
  
      References
      ----------
      Code excerpts from authors:
  
      * Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
      * Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
  
      http://scikit-learn.org/stable/auto_examples/calibration/plot_calibration_curve.html#sphx-glr-auto-examples-calibration-plot-calibration-curve-py
  
      """
  
      logger.info("Generating Calibration Plot")
  
      # For classification only
  
      if model.specs["model_type"] != ModelType.classification:
          logger.info("Calibration plot is for classification only")
          return None
  
      # Get X, Y for correct partition
  
      X, y = get_partition_data(model, partition)
  
      plt.style.use("classic")
      plt.figure(figsize=(10, 10))
      ax1 = plt.subplot2grid((3, 1), (0, 0), rowspan=2)
      ax2 = plt.subplot2grid((3, 1), (2, 0))
  
      ax1.plot([0, 1], [0, 1], "k:", label="Perfectly Calibrated")
      for algo in model.algolist:
          logger.info("Calibration for Algorithm: %s", algo)
          clf = model.estimators[algo]
          if hasattr(clf, "predict_proba"):
              prob_pos = model.probas[(algo, partition)]
          else:  # use decision function
              prob_pos = clf.decision_function(X)
              prob_pos = (prob_pos - prob_pos.min()) / (
                  prob_pos.max() - prob_pos.min()
              )
          (
              fraction_of_positives,
              mean_predicted_value,
          ) = calibration_curve(y, prob_pos, n_bins=10)
          ax1.plot(
              mean_predicted_value,
              fraction_of_positives,
              "s-",
              label="%s" % (algo,),
          )
          ax2.hist(
              prob_pos,
              range=(0, 1),
              bins=10,
              label=algo,
              histtype="step",
              lw=2,
          )
  
      ax1.set_ylabel("Fraction of Positives")
      ax1.set_ylim([-0.05, 1.05])
      ax1.legend(loc="lower right")
      ax1.set_title("Calibration Plots [Reliability Curve]")
  
      ax2.set_xlabel("Mean Predicted Value")
      ax2.set_ylabel("Count")
      ax2.legend(loc="upper center", ncol=2)
  
      plot_dir = get_plot_directory(model)
      pstring = datasets[partition]
      write_plot("matplotlib", plt, "calibration", pstring, plot_dir)
  
imports: from alphapy.estimators import get_estimators
  from alphapy.globals import BSEP, PSEP, SSEP, USEP
  from alphapy.globals import ModelType
  from alphapy.globals import Partition, datasets
  from alphapy.globals import Q1, Q3
  from alphapy.utilities import remove_list_items
  from bokeh.plotting import figure, show, output_file
  import itertools
  import logging
  import math
  import matplotlib
  import matplotlib.pyplot
  from mpl_toolkits.mplot3d import Axes3D
  import numpy
  import pandas
  from scipy import interp
  import seaborn
  from sklearn.calibration import calibration_curve
  from sklearn.inspection import partial_dependence
  from sklearn.inspection import plot_partial_dependence
  from sklearn.metrics import auc
  from sklearn.metrics import confusion_matrix
  from sklearn.metrics import roc_curve
  from sklearn.model_selection import cross_val_score
  from sklearn.model_selection import learning_curve
  from sklearn.model_selection import StratifiedKFold
  from sklearn.model_selection import train_test_split
  from sklearn.model_selection import validation_curve
  from sklearn.utils.multiclass import unique_labels
label_desc: Use image node_id 5 for calling a global function with example usage: plot_calibration(model, partition) and returns: None