MCPcopy Create free account
hub / github.com/ScottfreeLLC/AlphaPy / plot_learning_curve

Function plot_learning_curve

alphapy/plots.py:436–522  ·  view source on GitHub ↗

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 -------

(model, partition)

Source from the content-addressed store, hash-verified

434#
435
436def plot_learning_curve(model, partition):
437 r"""Generate learning curves for a given partition.
438
439 Parameters
440 ----------
441 model : alphapy.Model
442 The model object with plotting specifications.
443 partition : alphapy.Partition
444 Reference to the dataset.
445
446 Returns
447 -------
448 None : None
449
450 References
451 ----------
452
453 http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html
454
455 """
456
457 logger.info("Generating Learning Curves")
458 plot_dir = get_plot_directory(model)
459 pstring = datasets[partition]
460
461 # Extract model parameters.
462
463 cv_folds = model.specs['cv_folds']
464 n_jobs = model.specs['n_jobs']
465 seed = model.specs['seed']
466 shuffle = model.specs['shuffle']
467 verbosity = model.specs['verbosity']
468
469 # Get original estimators
470
471 estimators = get_estimators(model)
472
473 # Get X, Y for correct partition.
474
475 X, y = get_partition_data(model, partition)
476
477 # Set cross-validation parameters to get mean train and test curves.
478
479 cv = StratifiedKFold(n_splits=cv_folds, shuffle=shuffle, random_state=seed)
480
481 # Plot a learning curve for each algorithm.
482
483 ylim = (0.4, 1.01)
484
485 for algo in model.algolist:
486 logger.info("Learning Curve for Algorithm: %s", algo)
487 # get estimator
488 est = estimators[algo].estimator
489 # plot learning curve
490 title = BSEP.join([algo, "Learning Curve [", pstring, "]"])
491 # set up plot
492 plt.style.use('classic')
493 plt.figure()

Callers 1

generate_plotsFunction · 0.85

Calls 4

get_estimatorsFunction · 0.90
get_plot_directoryFunction · 0.85
get_partition_dataFunction · 0.85
write_plotFunction · 0.85

Tested by

no test coverage detected