Advice for applying machine learning Deciding what to

  • Slides: 30
Download presentation
Advice for applying machine learning Deciding what to try next Machine Learning

Advice for applying machine learning Deciding what to try next Machine Learning

Debugging a learning algorithm: Suppose you have implemented regularized linear regression to predict housing

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? - Get more training examples Try smaller sets of features Try getting additional features Try adding polynomial features Try decreasing Try increasing Andrew Ng

Machine learning diagnostic: Diagnostic: A test that you can run to gain insight what

Machine learning diagnostic: Diagnostic: A test that you can run to gain insight what is/isn’t working with a learning algorithm, and gain guidance as to how best to improve its performance. Diagnostics can take time to implement, but doing so can be a very good use of your time. Andrew Ng

Advice for applying machine learning Evaluating a hypothesis Machine Learning

Advice for applying machine learning Evaluating a hypothesis Machine Learning

Evaluating your hypothesis price Fails to generalize to new examples not in training set.

Evaluating your hypothesis price Fails to generalize to new examples not in training set. size of house no. of bedrooms no. of floors age of house average income in neighborhood kitchen size Andrew Ng

Evaluating your hypothesis Dataset: Size Price 2104 1600 2400 1416 3000 1985 1534 1427

Evaluating your hypothesis Dataset: Size Price 2104 1600 2400 1416 3000 1985 1534 1427 1380 1494 400 330 369 232 540 300 315 199 212 243 Andrew Ng

Training/testing procedure for linear regression - Learn parameter from training data (minimizing training error

Training/testing procedure for linear regression - Learn parameter from training data (minimizing training error ) - Compute test set error: Andrew Ng

Training/testing procedure for logistic regression - Learn parameter from training data - Compute test

Training/testing procedure for logistic regression - Learn parameter from training data - Compute test set error: - Misclassification error (0/1 misclassification error): Andrew Ng

Advice for applying machine learning Model selection and training/validation/test sets Machine Learning

Advice for applying machine learning Model selection and training/validation/test sets Machine Learning

price Overfitting example size Once parameters were fit to some set of data (training

price Overfitting example size Once parameters were fit to some set of data (training set), the error of the parameters as measured on that data (the training error xxxxx) is likely to be lower than the actual generalization error. Andrew Ng

Model selection 1. 2. 3. 10. Choose How well does the model generalize? Report

Model selection 1. 2. 3. 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. Andrew Ng

Evaluating your hypothesis Dataset: Size Price 2104 1600 2400 1416 3000 1985 1534 1427

Evaluating your hypothesis Dataset: Size Price 2104 1600 2400 1416 3000 1985 1534 1427 1380 1494 400 330 369 232 540 300 315 199 212 243 Andrew Ng

Train/validation/test error Training error: Cross Validation error: Test error: Andrew Ng

Train/validation/test error Training error: Cross Validation error: Test error: Andrew Ng

Model selection 1. 2. 3. 10. Pick Estimate generalization error for test set Andrew

Model selection 1. 2. 3. 10. Pick Estimate generalization error for test set Andrew Ng

Advice for applying machine learning Diagnosing bias vs. variance Machine Learning

Advice for applying machine learning Diagnosing bias vs. variance Machine Learning

Size High bias (underfit) Price Bias/variance Size “Just right” Size High variance (overfit) Andrew

Size High bias (underfit) Price Bias/variance Size “Just right” Size High variance (overfit) Andrew Ng

Bias/variance Training error: error Cross validation error: degree of polynomial d Andrew Ng

Bias/variance Training error: error Cross validation error: degree of polynomial d Andrew Ng

Diagnosing bias vs. variance error Suppose your learning algorithm is performing less well than

Diagnosing bias vs. variance error 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) Variance (overfit): (training error) degree of polynomial d Andrew Ng

Advice for applying machine learning Regularization and bias/variance Machine Learning

Advice for applying machine learning Regularization and bias/variance Machine Learning

Linear regression with regularization Price Model: Size Large xx High bias (underfit) Intermediate xx

Linear regression with regularization Price Model: Size Large xx High bias (underfit) Intermediate xx “Just right” Size Small xx High variance (overfit) Andrew Ng

Choosing the regularization parameter Andrew Ng

Choosing the regularization parameter Andrew Ng

Choosing the regularization parameter Model: 1. 2. 3. 4. 5. Try Try Try 12.

Choosing the regularization parameter Model: 1. 2. 3. 4. 5. Try Try Try 12. Try Pick (say) . Test error: Andrew Ng

Bias/variance as a function of the regularization parameter Andrew Ng

Bias/variance as a function of the regularization parameter Andrew Ng

Advice for applying machine learning Learning curves Machine Learning

Advice for applying machine learning Learning curves Machine Learning

error Learning curves (training set size) Andrew Ng

error Learning curves (training set size) Andrew Ng

error price High bias (training set size) If a learning algorithm is suffering from

error price High bias (training set size) If a learning algorithm is suffering from high bias, getting more training data will not (by itself) help much. price size Andrew Ng

High variance ) error price (and small (training set size) If a learning algorithm

High variance ) error price (and small (training set size) If a learning algorithm is suffering from high variance, getting more training data is likely to help. price size Andrew Ng

Advice for applying machine learning Deciding what to try next (revisited) Machine Learning

Advice for applying machine learning Deciding what to try next (revisited) Machine Learning

Debugging a learning algorithm: Suppose you have implemented regularized linear regression to predict housing

Debugging a learning algorithm: Suppose you have implemented regularized linear regression to predict housing prices. However, when you test your hypothesis in a new set of houses, you find that it makes unacceptably large errors in its prediction. What should you try next? - Get more training examples Try smaller sets of features Try getting additional features Try adding polynomial features Try decreasing Try increasing Andrew Ng

Neural networks and overfitting “Small” neural network (fewer parameters; more prone to underfitting) Computationally

Neural networks and overfitting “Small” neural network (fewer parameters; more prone to underfitting) Computationally cheaper “Large” neural network (more parameters; more prone to overfitting) Computationally more expensive. Use regularization ( ) to address overfitting. Andrew Ng