August 2018
Intermediate to advanced
522 pages
12h 45m
English
In many tasks, it's helpful to check how the number of samples impacts training performance. This can be achieved by plotting a learning curve, which is normally based on both training and validation scores (preferably CV score). Let's consider the Wine dataset and a simple logistic regression. scikit-learn provides the built-in learning_curve() function, which can automatically compute the scores for a different number of training samples:
import numpy as npfrom sklearn.datasets import load_winefrom sklearn.model_selection import learning_curvefrom sklearn.linear_model import LogisticRegressionfrom sklearn.utils import shufflewine = load_wine()X, Y = shuffle(wine['data'], wine['target'])tsize, training_score, test_score = ...
Read now
Unlock full access