code: def plot_validation_curve(model, partition, pname, prange):
      r"""Generate scikit-learn validation curves.
  
      Parameters
      ----------
      model : alphapy.Model
          The model object with plotting specifications.
      partition : alphapy.Partition
          Reference to the dataset.
      pname : str
          Name of the hyperparameter to test.
      prange : numpy array
          The values of the hyperparameter that will be evaluated.
  
      Returns
      -------
      None : None
  
      References
      ----------
  
      http://scikit-learn.org/stable/auto_examples/model_selection/plot_validation_curve.html#sphx-glr-auto-examples-model-selection-plot-validation-curve-py
  
      """
  
      logger.info("Generating Validation Curves")
      plot_dir = get_plot_directory(model)
      pstring = datasets[partition]
  
      # Extract model parameters.
  
      cv_folds = model.specs["cv_folds"]
      n_jobs = model.specs["n_jobs"]
      scorer = model.specs["scorer"]
      verbosity = model.specs["verbosity"]
  
      # Get X, Y for correct partition.
  
      X, y = get_partition_data(model, partition)
  
      # Define plotting constants.
  
      spacing = 0.5
      alpha = 0.2
  
      # Calculate a validation curve for each algorithm.
  
      for algo in model.algolist:
          logger.info("Algorithm: %s", algo)
          # get estimator
          estimator = model.estimators[algo]
          # set up plot
          train_scores, test_scores = validation_curve(
              estimator,
              X,
              y,
              param_name=pname,
              param_range=prange,
              cv=cv_folds,
              scoring=scorer,
              n_jobs=n_jobs,
          )
          train_scores_mean = np.mean(train_scores, axis=1)
          train_scores_std = np.std(train_scores, axis=1)
          test_scores_mean = np.mean(test_scores, axis=1)
          test_scores_std = np.std(test_scores, axis=1)
          # set up figure
          plt.style.use("classic")
          plt.figure()
          # plot learning curves
          title = BSEP.join([algo, "Validation Curve [", pstring, "]"])
          plt.title(title)
          # x-axis
          x_min, x_max = min(prange) - spacing, max(prange) + spacing
          plt.xlabel(pname)
          plt.xlim(x_min, x_max)
          # y-axis
          plt.ylabel("Score")
          plt.ylim(0.0, 1.1)
          # plot scores
          plt.plot(
              prange,
              train_scores_mean,
              label="Training Score",
              color="r",
          )
          plt.fill_between(
              prange,
              train_scores_mean - train_scores_std,
              train_scores_mean + train_scores_std,
              alpha=alpha,
              color="r",
          )
          plt.plot(
              prange,
              test_scores_mean,
              label="Cross-Validation Score",
              color="g",
          )
          plt.fill_between(
              prange,
              test_scores_mean - test_scores_std,
              test_scores_mean + test_scores_std,
              alpha=alpha,
              color="g",
          )
          plt.legend(loc="best")  # save the plot
          tag = USEP.join([pstring, algo])
          write_plot(
              "matplotlib", plt, "validation_curve", tag, 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 10 for calling a global function with example usage: plot_validation_curve(model, partition, pname, prange) without return types