Skip to content

Instantly share code, notes, and snippets.

@kocur4d
Created July 6, 2018 15:28
Show Gist options
  • Save kocur4d/0c8c231a5338ec1185c5230bcc37d599 to your computer and use it in GitHub Desktop.
Save kocur4d/0c8c231a5338ec1185c5230bcc37d599 to your computer and use it in GitHub Desktop.
lr
from sklearn.learning_curve import learning_curve
import numpy as np
import matplotlib.pyplot as plt
N, train_lc, val_lc = learning_curve(svc_clf, X_train, y_train, cv=7, train_sizes=np.linspace(0.3, 1, 25))
plt.plot(N, np.mean(train_lc, 1), color='blue', label='training score')
plt.plot(N, np.mean(val_lc, 1), color='red', label='validation score')
plt.hlines(np.mean([train_lc[-1], val_lc[-1]]), N[0], N[-1], color='gray', linestyle='dashed')
plt.set_ylim(0, 1)
plt.set_xlim(N[0], N[-1])
plt.set_xlabel('training size')
plt.set_ylabel('score')
plt.legend(loc='best')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment