10 Advice For Applying Machine Learning
10 Advice For Applying Machine Learning
Machine Learning
2
Debugging a learning algorithm:
Suppose you have implemented regularized linear regression to predict housing
prices.
However, when you test your hypothesis on a new set of houses, you find that it
makes unacceptably large errors in its predictions. What should you try next?
4
Evaluating a hypothesis
5
Evaluating your hypothesis
Try to minimize the training error
Fitting parameters to training data
doesn’t always work
price
6
Standard way to evaluate a hypothesis
Dataset:
Size Price
2104 400
1600 330
2400 369
1416 232
3000 540
1985 300
1534 315
1427 199
1380 212
1494 243
7
Training/testing procedure for linear regression
8
Training/testing procedure for logistic regression
- Learn parameter from training data
- Compute test set error:
Once parameters
price
10.
Choose
How well does the model generalize? Report test set
error .
Problem: is likely to be an optimistic estimate of
generalization error. i.e. our extra parameter ( = degree of
polynomial) is fit to test set. So not a good way to evaluate if it will generalize 12
Improved model selection
Dataset:
Size Price
2104 400
1600 330
2400 369
1416 232
3000 540
1985 300
1534 315
1427 199
1380 212
1494 243
13
Train/validation/test error
Training error:
Test error:
14
Model selection
1.
2.
3.
10.
Pick
Estimate generalization error for test set
15
Train/validation/test sets
• In machine learning as practiced today
– Many people will select the model using the test set
and then check the model is OK for generalization using
the test error
– We've said is bad because it gives a bias analysis
• With a MASSIVE test set this is maybe OK
• But considered much better practice to have
separate training and validation sets
Diagnosing bias vs. variance
Underfitting vs. overfitting
17
•
Bias/variance • One of the main reasons for getting bad results
Important to work out if it is bias or variance
• Knowing it will help you to improve the algorithm
Price
Price
Price
Size Size Size
18
Bias/variance
Training error:
19
Bias/variance
Training error:
error
degree of polynomial d
20
Diagnosing bias vs. variance
Suppose your learning algorithm is performing less well than
you were hoping. ( or is high.) Is it a bias
problem or a variance problem?
Bias (underfit):
(cross validation
error
error)
Variance (overfit):
(training error)
degree of polynomial d
21
Diagnosing bias vs. variance
Suppose your learning algorithm is performing less well than
you were hoping. ( or is high.) Is it a bias
problem or a variance problem?
Bias (underfit):
(cross validation
error
error)
Variance (overfit):
(training error)
degree of polynomial d
22
Diagnosing bias vs. variance
Suppose your learning algorithm is performing less well than
you were hoping. ( or is high.) Is it a bias
problem or a variance problem?
Bias (underfit):
(cross validation
will be high
error
error)
Variance (overfit):
(training error)
will be low
degree of polynomial d
23
Neural networks and overfitting
“Small” neural network “Large” neural network
(fewer parameters; more (more parameters; more prone
prone to underfitting) to overfitting)
24
End
25