Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

learning curve doc #818

Merged
merged 1 commit into from
Apr 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
learning curve doc
rasbt committed Apr 18, 2021
commit 3b99cb21e6f16b5c06ff371824f83588f27f6f4a
1 change: 1 addition & 0 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ The CHANGELOG for the current development version is available at
- Updates unit tests for scikit-learn 0.24.1 compatibility. ([#774](https://github.com/rasbt/mlxtend/pull/774))
- `StackingRegressor` now requires setting `StackingRegressor(..., multi_output=True)` if the target is multi-dimensional; this allows for better input validation. ([#802](https://github.com/rasbt/mlxtend/pull/802))
- Removes deprecated `res` argument from `plot_decision_regions`. ([#803](https://github.com/rasbt/mlxtend/pull/803))
- Adds a `title_fontsize` parameter to `plot_learning_curves` for controlling the title font size; also the plot style is now the matplotlib default. ([#818](https://github.com/rasbt/mlxtend/pull/818))

##### Bug Fixes

61 changes: 47 additions & 14 deletions docs/sources/user_guide/plotting/plot_learning_curves.ipynb

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions mlxtend/plotting/learning_curves.py
Original file line number Diff line number Diff line change
@@ -16,8 +16,10 @@ def plot_learning_curves(X_train, y_train,
train_marker='o',
test_marker='^',
scoring='misclassification error',
suppress_plot=False, print_model=True,
style='fivethirtyeight',
suppress_plot=False,
print_model=True,
title_fontsize=12,
style='default',
legend_loc='best'):
"""Plots learning curves of a classifier.
@@ -49,8 +51,11 @@ def plot_learning_curves(X_train, y_train,
for testing purposes.
print_model : bool (default: True)
Print model parameters in plot title if True.
style : str (default: 'fivethirtyeight')
Matplotlib style
title_fontsize : int (default: 12)
Determines the size of the plot title font.
style : str (default: 'default')
Matplotlib style. For more styles, please see
https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html
legend_loc : str (default: 'best')
Where to place the plot legend:
{'best', 'upper left', 'upper right', 'lower left', 'lower right'}
@@ -124,7 +129,9 @@ def misclf_err(y_predict, y):
with plt.style.context(style):
plt.ylabel('Performance ({})'.format(scoring))
if print_model:
plt.title('Learning Curves\n\n{}\n'.format(model))
plt.title(
'Learning Curves\n\n{}\n'.format(model),
fontsize=title_fontsize)
plt.legend(loc=legend_loc, numpoints=1)
plt.xlim([0, 110])
max_y = max(max(test_errors), max(training_errors))