Validation and Testing
COMPSCI 371D — Machine Learning
COMPSCI 371D — Machine Learning Validation and Testing 1 / 19
Validation and Testing COMPSCI 371D Machine Learning COMPSCI 371D - - PowerPoint PPT Presentation
Validation and Testing COMPSCI 371D Machine Learning COMPSCI 371D Machine Learning Validation and Testing 1 / 19 Outline 1 Training, Testing, and Model Selection 2 A Generative Data Model 3 Model Selection: Validation 4 Model Selection:
COMPSCI 371D — Machine Learning Validation and Testing 1 / 19
1 Training, Testing, and Model Selection 2 A Generative Data Model 3 Model Selection: Validation 4 Model Selection: Cross-Validation 5 Model Selection: The Bootstrap
COMPSCI 371D — Machine Learning Validation and Testing 2 / 19
Training, Testing, and Model Selection
def
1 |T|
COMPSCI 371D — Machine Learning Validation and Testing 3 / 19
Training, Testing, and Model Selection
COMPSCI 371D — Machine Learning Validation and Testing 4 / 19
Training, Testing, and Model Selection
COMPSCI 371D — Machine Learning Validation and Testing 5 / 19
A Generative Data Model
def
COMPSCI 371D — Machine Learning Validation and Testing 6 / 19
A Generative Data Model
COMPSCI 371D — Machine Learning Validation and Testing 7 / 19
A Generative Data Model
COMPSCI 371D — Machine Learning Validation and Testing 8 / 19
A Generative Data Model
COMPSCI 371D — Machine Learning Validation and Testing 9 / 19
Model Selection: Validation
π∈Π Hπ
π∈Π LV(ERMT(Hπ))
COMPSCI 371D — Machine Learning Validation and Testing 10 / 19
Model Selection: Validation
COMPSCI 371D — Machine Learning Validation and Testing 11 / 19
Model Selection: Validation
2 4 6 8 10 0.5 1 1.5
training risk validation risk
1 5
k = 1 k = 2 k = 3 k = 6 k = 9
COMPSCI 371D — Machine Learning Validation and Testing 12 / 19
Model Selection: Cross-Validation
π and on all of T
COMPSCI 371D — Machine Learning Validation and Testing 13 / 19
Model Selection: Cross-Validation
π and on all of T
COMPSCI 371D — Machine Learning Validation and Testing 14 / 19
Model Selection: Cross-Validation
procedure CROSSVALIDATION(H, Π, T, K, ℓ) {V1, . . . , VK } = SPLIT(T, K) ⊲ Split T in K approximately equal-sized sets at random ˆ L = ∞ ⊲ Will hold the lowest risk over Π for π ∈ Π do s, s2 = 0, 0 ⊲ Will hold sum of risks and their squares to compute risk mean and variance for k = 1, . . . , K do Tk = T \ Vk ⊲ Use all of T except Vk as training set h ∈ arg minh′∈Hπ LTk (h′) ⊲ Use the loss ℓ to compute h = ERMTk (Hπ) L = LVk (h) ⊲ Use the loss ℓ to compute the risk of h on Vk (s, s2) = (s + L, s2 + L2) ⊲ Keep track of quantities to compute risk mean and variance end for L = s/K ⊲ Sample mean of the risk over the K folds if L < ˆ L then σ2 = (s2 − s2/K)/(K − 1) ⊲ Sample variance of the risk over the K folds ( ˆ π, ˆ L, ˆ σ2) = (π, L, σ2) ⊲ Keep track of the best hyper-parameters and their risk statistics end if end for ˆ h = arg minh∈H ˆ
π LT (h)
⊲ Train predictor afresh on all of T with the best hyper-parameters return ( ˆ π, ˆ h, ˆ L, ˆ σ2) ⊲ Return best hyper-parameters, predictor, and risk statistics end procedure COMPSCI 371D — Machine Learning Validation and Testing 15 / 19
Model Selection: Cross-Validation
COMPSCI 371D — Machine Learning Validation and Testing 16 / 19
Model Selection: The Bootstrap
N
n=1 ℓ(yn, h(xn)) = 1 N
j=1 mj ℓ(yj, h(xj))
COMPSCI 371D — Machine Learning Validation and Testing 17 / 19
Model Selection: The Bootstrap
N
e ≈ 0.37
COMPSCI 371D — Machine Learning Validation and Testing 18 / 19
Model Selection: The Bootstrap
COMPSCI 371D — Machine Learning Validation and Testing 19 / 19