訓練集、驗證集與測試集:先固定比較方式
僅在記錄預測與觀察證據之後允許求助。
前置要求
完成第 28 天統計;掌握預測—回顧流程。
學習目標
解釋訓練/驗證/測試劃分在評估中的作用,以及為什麼測試集只讀取一次;在任何調參之前先固定評估協議。
操作指引
評估回答的問題是『模型能否泛化』,使用的資料模型在訓練中從未見過。訓練集擬合參數;驗證集指導選擇(選哪個模型、哪些設定);測試集是最終的、未動過的讀取。1,000 個樣本按 60/20/20 劃分為 600 訓練、200 驗證、200 測試。只有當每個候選都在同一劃分上用同一指標打分時,比較才有效——先固定協議再調參,而不是看到結果之後再改。
自主實作與記錄
某學習者有 1,000 個標註樣本。(a) 按 60/20/20 分配訓練/驗證/測試。(b) 模型 M1 是在測試集上試評 40 次後選出的——指出協議違規及其後果。(c) 說明比較 M1 與 M2 得分前必須保持一致的條件。
反覆讀取測試集會讓『測試』退化為驗證——報告值樂觀偏置。比較前必須相同:同一保留資料、同一指標、同一預處理。
(a) 600 訓練、200 驗證、200 測試。(b) 測試集被重複用於模型選擇,報告分數向上偏置——違規點是『在測試集上做選擇』;修復方法是用驗證集做選擇、測試集只讀一次。(c) 同一測試劃分、同一指標、同一預處理與評估程式碼,否則差異無法解釋。
說明各劃分在評估中的作用,指出測試集複用違規,並在調參前寫出固定協議清單。
權威來源資源與權利證明
Dive into Deep Learning (d2l.ai)
對應章節 / 時間戳: Section: Model Selection, Underfitting, and Overfitting
驗證版本與日期: Current online edition (Verified: 2026-10-30)
Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.
Linear algebra, calculus, and probability at the Days 19-28 level.
All required formulas and worked numbers are reproduced as original explanations; the book is further reading.
對比候選資源與選型分析 (2)
Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.
Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.
Google Machine Learning Crash Course
對應章節 / 時間戳: Modules: Training and Test Sets; Validation
驗證版本與日期: Current online edition (Verified: 2026-10-30)
Industrial, beginner-legible treatment of training/test splitting and overfitting; complements d2l.ai's mathematical framing.
Basic algebra; short self-contained modules.
Split discipline, leakage rules, and metric definitions are fully explained inside the lesson; the course is further reading.
對比候選資源與選型分析 (2)
Co-primary: deeper mathematical coverage of model selection, generalization, and optimization for the mathematics-track capstone.
Normative reference once learners call sklearn; kept as an alternative because these days teach evaluation protocol before library usage.