ML 04 Validation Regularization
ML 04 Validation Regularization
Machine Learning
• Classification
– Whether predicted classes match the actual
classes
Evaluation metrics for Regression
• Mean Squared Error (MSE)
– For every data point, compute error (distance between
predicted value and actual value)
– Sum squares of these errors, and take average
– More popular variant: RMSE (square root of MSE)
• R2 or R-squared
– A naïve Simple Average Model (SAM): for every point,
predict the average of all points
– R2: 1 – (error of model / error of SAM)
– Best possible R2 is 1; can be negative for a really bad model
R2 or R-squared
• Dataset has n instances <xi , yi>, i=1..N
• Predicted values: fi, i=1..N
• Mean of actual values:
h=1 h = -1
• Application 1: Supermarket
verifies customers for giving a
discount
y
• Application 1: Supermarket
verifies customers for giving a
discount
y
• Application 1: Supermarket
verifies customers for giving a
discount
y
• Application 2: For entering
into RAW, GoI
On what data to measure
precision, recall, error rate, ..?
• Option 1: training set
• Option 2: some other set of examples that was
unknown at the time of training (test set)
Size
Fitting a linear function
Size
Bias vs. variance in linear regression
Price
Size
Size
• Regularization
– Constraint the model so that the noise cannot be
learnt too well
Validation
Validation
• Holdout method
– Split data into train and test set (usually 2/3 for
train and 1/3 for test). Learn model using train set
and measure performance over test set
Classifier
2. Regularization
― Keep all the features, but reduce magnitude/values of
parameters
― Works well when we have a lot of features, each of which
contributes a bit to predicting
Intuition of regularization
Price
Price
λ: Regularization parameter
Regularization parameter
- Controls trade-off between our two goals
- (1) fitting the training data well
- (2) keeping values of parameters small
Repeat
Gradient Descent for Regularized Logistic Regression
Gradient Descent for Regularized Logistic Regression
Repeat
Bias vs. Variance
A closer look
Example: Linear regression
Price
Size