code: def plot_learning_curve(model, partition):
      r"""Generate learning curves for a given partition.
  
      Parameters
      ----------
      model : alphapy.Model
          The model object with plotting specifications.
      partition : alphapy.Partition
          Reference to the dataset.
  
      Returns
      -------
      None : None
  
      References
      ----------
  
      http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html
  
      """
  
      logger.info("Generating Learning 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"]
      seed = model.specs["seed"]
      shuffle = model.specs["shuffle"]
      verbosity = model.specs["verbosity"]
  
      # Get original estimators
  
      estimators = get_estimators(model)
  
      # Get X, Y for correct partition.
  
      X, y = get_partition_data(model, partition)
  
      # Set cross-validation parameters to get mean train and test curves.
  
      cv = StratifiedKFold(
          n_splits=cv_folds, shuffle=shuffle, random_state=seed
      )
  
      # Plot a learning curve for each algorithm.
  
      ylim = (0.4, 1.01)
  
      for algo in model.algolist:
          logger.info("Learning Curve for Algorithm: %s", algo)
          # get estimator
          est = estimators[algo].estimator
          # plot learning curve
          title = BSEP.join([algo, "Learning Curve [", pstring, "]"])
          # set up plot
          plt.style.use("classic")
          plt.figure()
          plt.title(title)
          if ylim is not None:
              plt.ylim(*ylim)
          plt.xlabel("Training Examples")
          plt.ylabel("Score")
          # call learning curve function
          train_sizes = np.linspace(0.1, 1.0, cv_folds)
          train_sizes, train_scores, test_scores = learning_curve(
              est,
              X,
              y,
              train_sizes=train_sizes,
              cv=cv,
              n_jobs=n_jobs,
              verbose=verbosity,
          )
          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)
          plt.grid()
          # plot data
          plt.fill_between(
              train_sizes,
              train_scores_mean - train_scores_std,
              train_scores_mean + train_scores_std,
              alpha=0.1,
              color="r",
          )
          plt.fill_between(
              train_sizes,
              test_scores_mean - test_scores_std,
              test_scores_mean + test_scores_std,
              alpha=0.1,
              color="g",
          )
          plt.plot(
              train_sizes,
              train_scores_mean,
              "o-",
              color="r",
              label="Training Score",
          )
          plt.plot(
              train_sizes,
              test_scores_mean,
              "o-",
              color="g",
              label="Cross-Validation Score",
          )
          plt.legend(loc="lower right")
          # save the plot
          tag = USEP.join([pstring, algo])
          write_plot("matplotlib", plt, "learning_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 7 for calling a global function with example usage: plot_learning_curve(model, partition) without return types