Plotting Learning Curves


In [1]:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -d -v -p matplotlib


Sebastian Raschka 09/04/2015 

CPython 3.4.3
IPython 3.1.0

matplotlib 1.4.3

In [2]:
import sys
sys.path = ['/Users/sebastian/github/mlxtend'] + sys.path

import mlxtend
from mlxtend.evaluate import plot_learning_curves
#mlxtend.__version__

In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.cross_validation import train_test_split
import numpy as np

# Loading some example data
iris = datasets.load_iris()
X = iris.data
y = iris.target

X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.6, random_state=2)

In [4]:
from sklearn.tree import DecisionTreeClassifier
import numpy as np

clf = DecisionTreeClassifier(max_depth=1)

plot_learning_curves(X_train, y_train, X_test, y_test, clf, kind='training_size')
plt.show()

plot_learning_curves(X_train, y_train, X_test, y_test, clf, kind='n_features')
plt.show()