WARIN.ME · INTERACTIVE ML OPERATIONS

โมเดลไม่ได้หยุดเรียนรู้
เมื่อเรา Deploy
A model does not stop learning
when we deploy it

Website → Features → Prediction → Drift → Retraining → Champion/ChallengerWebsite → Features → Prediction → Drift → Retraining → Champion/Challenger

เวลาจำลองSimulated time
MONTH 0 / 24
Ready to begin
Champion
v001
Initial 2012
F1 / Balanced Accuracy
—
อย่าดู Accuracy อย่างเดียวAccuracy alone is insufficient
Feature drift
READY
—
การตัดสินใจDecision
WAITING
—
โหมดสอน:Teaching mode: Manual Trigger · เทียบเท่า Production:Production equivalent: 0 2 1 * * · IDLE

Champion v001 กับ v002 เปลี่ยนอะไร?What changed between Champion v001 and v002?

เลขเวอร์ชันหมายถึง model artifact ที่ deploy ไม่ได้แปลว่าต้องเปลี่ยน algorithm เสมอ โมเดลใหม่อาจใช้ algorithm เดิม แต่ฝึกใหม่ด้วยข้อมูลและ window ที่ต่างออกไปThe version identifies a deployed model artifact. It does not necessarily mean a new algorithm; a new artifact may retrain the same algorithm on different data and a different window.

ChampionAlgorithmFeature setTraining windowข้อมูลฝึกTraining dataสิ่งที่เปลี่ยนWhat changedเหตุผล DeployDeployment reason
v001Logistic RegressionEngineeredInitial 2012Jan–Dec 2012รุ่นเริ่มต้นInitial artifactผ่าน design validationPassed design validation
v002Logistic RegressionEngineeredExpandingJan 2011–Oct 2013Window + ข้อมูล + coefficientsWindow + data + coefficients2013-11 · ΔF1 +0.0233 · PROMOTE
v003?Random Forest candidateEngineeredต้องแข่งขัน 7 windowsMust compete across 7 windowsกำหนด ณ retraining eventDefined at the retraining eventAlgorithm อาจเปลี่ยนจริงAlgorithm may truly changeยังไม่ Deploy — ต้องผ่าน walk-forward และ guardrailsNot deployed—must pass walk-forward tests and guardrails
v001 → v002เปลี่ยน artifactArtifact changed
LR → LRAlgorithm ไม่เปลี่ยนAlgorithm unchanged
Initial → ExpandingWindow เปลี่ยนWindow changed
คำที่ควรใช้ในชั้นเรียน: “ระบบ Promote model artifact ใหม่ แต่ยังคง model family เดิม” ส่วนคำว่า “เปลี่ยน algorithm” ให้ใช้เมื่อผู้ชนะเปลี่ยนจาก LR ไปเป็น RF/HGB จริงเท่านั้นClassroom wording: “The system promoted a new model artifact while keeping the same model family.” Say “the algorithm changed” only when a different family such as RF/HGB actually wins.

Algorithm Benchmark — ก่อนเลือกโมเดลAlgorithm benchmark — before model selection

การทดลองนี้ควบคุมให้ทุก algorithm เห็น engineered features ชุดเดียวกัน ฝึกด้วย Jan–Sep 2012 และประเมินบนข้อมูลอนาคต Oct–Dec 2012 โดยไม่สุ่มสลับเวลา ไม่มี hyperparameter search และใช้ F1 เป็น primary metricEvery algorithm sees the same engineered features, trains on Jan–Sep 2012, and is evaluated on the later Oct–Dec 2012 holdout. There is no hyperparameter search; F1 is the primary metric.

AlgorithmลักษณะFamilyAccuracyBalanced Acc.PrecisionRecallF1ROC-AUCผลตาม F1F1 result
Random ForestBagging trees0.8430.7450.6910.5640.6210.852WINNER ✓
Logistic RegressionLinear0.7760.7550.5070.7160.5930.829Teaching baselineTeaching baseline
Histogram Gradient BoostingBoosted trees0.8220.7260.6260.5500.5850.816—
อ่านผลอย่างระวัง: Random Forest ชนะตาม F1 (+0.028 เทียบ LR) และ ROC-AUC แต่ LR มี Balanced Accuracy และ Recall สูงกว่า จึงยังสรุปไม่ได้ว่า RF ดีกว่าทุกมิติ หาก policy ยืนยันว่า F1 คือเป้าหมายหลัก RF คือ algorithm candidate ที่ควรนำไปทดสอบแบบ walk-forward ต่อ ส่วน simulation ที่แสดงด้านล่างยังใช้ LR เพื่อแยกผลของ 7 training windows อย่างควบคุมRead carefully: Random Forest wins F1 (+0.028 over LR) and ROC-AUC, while LR has higher Balanced Accuracy and Recall. RF is therefore the next walk-forward candidate if F1 remains the primary objective. The simulation below still holds LR fixed to isolate the effects of seven training windows.

ข้อจำกัด: นี่เป็น holdout เดียวและ configuration ที่กำหนดไว้ล่วงหน้า ยังไม่ใช่ข้อสรุป production ควรเพิ่ม rolling-origin cross-validation, probability calibration, latency/model-size และ hyperparameter tuning แบบ nested temporal validation ก่อนอนุมัติเปลี่ยน algorithmLimitation: this is one holdout with preset configurations, not a production verdict. Add rolling-origin cross-validation, calibration, latency/model-size checks, and hyperparameter tuning with nested temporal validation before changing the deployed algorithm.

ข้อมูลและโจทย์ที่โมเดลแก้Data and prediction problem

ใช้ UCI ElectricityLoadDiagrams2011–2014 จากลูกค้าไฟฟ้า 36 รายที่ข้อมูลต่อเนื่อง รวมข้อมูลทุก 15 นาทีเป็นหนึ่งแถวต่อ client-day แล้วแบ่งพลังงานเป็น Night, Morning, Afternoon, Evening และ TotalWe use 36 continuous clients from UCI ElectricityLoadDiagrams2011–2014. The 15-minute readings are aggregated into one client-day row with Night, Morning, Afternoon, Evening, and Total energy.

36ลูกค้าclients
26,280แถวจำลองsimulation rows
24เดือน (2013–2014)months (2013–2014)

Target label: HIGH / LOW — พยากรณ์ว่าโหลด “วันพรุ่งนี้” จะสูงกว่าค่ามัธยฐานแบบ expanding ของลูกค้ารายนั้น ในเดือนปฏิทินและวันในสัปดาห์เดียวกันหรือไม่ จึงรักษาขอบเขตการทำนายล่วงหน้า 1 วันpredict whether tomorrow's load exceeds that client's expanding historical median for the same calendar month and weekday, preserving a strict one-day prediction boundary.

สร้างกี่โมเดล และตัดสินใจอย่างไรHow many models, and how we decide

เดือนปกติใช้ Champion 1 โมเดลทำนายและไม่ฝึกใหม่ เมื่อ drift/performance trigger ทำงาน จึงฝึก Challenger 7 โมเดลจากหน้าต่างข้อมูลต่างกัน แล้วนำมาเทียบกับ Champion เดิม รวม 8 แถวในการแข่งขันIn a normal month, one Champion predicts and nothing is retrained. A drift/performance trigger trains seven Challengers on different windows and compares them with the current Champion: eight competition rows.

7 windows: Expanding · Recent 3M · Rolling 6M · Rolling 12M · Tumbling 3M · Seasonal-2Y · Hybrid

เดือนนี้: ยังไม่มีการฝึกโมเดลใหม่This month: no new model training yet

ผู้ชนะไม่ได้เป็น Champion อัตโนมัติ: ต้องเพิ่ม F1 อย่างน้อย 0.02 และผ่าน Balanced Accuracy guardrail ตลอด 24 เดือน lab สร้าง Challenger 28 artifacts จาก 4 retraining events และ Promote จริง 1 ครั้งA winner is not promoted automatically: it needs at least +0.02 F1 and must pass the Balanced Accuracy guardrail. Across 24 months, the lab creates 28 Challenger artifacts in four retraining events and promotes once.

โมเดลที่เลือกใช้: อะไรคงที่ อะไรเป็นตัวแข่งขัน?Selected model: what stays fixed, and what competes?

Algorithm: Logistic Regression

ทุก Champion และ Challenger ใช้ binary Logistic Regression แบบเดียวกัน โดยตั้ง class_weight=balanced, solver=lbfgs และ max_iter=2000 สิ่งที่แข่งขันใน lab คือ “ข้อมูลช่วงไหนควรใช้ฝึก” ไม่ใช่ “algorithm ใดชนะ”Every Champion and Challenger uses the same binary Logistic Regression with class_weight=balanced, solver=lbfgs, and max_iter=2000. The experiment varies the training history, not the algorithm.

P(HIGH tomorrow | X) → threshold 0.50

ขั้น preprocessing อยู่ใน Pipeline เดียวกับโมเดล: ตัวเลขเติม missing ด้วย median แล้ว Standardize; หมวดหมู่เติมด้วย most frequent แล้ว One-hot encode จึงลด train/serve skew และป้องกัน preprocessing leakagePreprocessing ships in the same Pipeline: numeric values use median imputation plus standardization; categorical values use most-frequent imputation plus one-hot encoding. This reduces train/serve skew and prevents preprocessing leakage.

ทำไมเลือก Logistic Regression?Why Logistic Regression? เป็น baseline ที่ตีความ coefficient ได้ ฝึก Challenger 7 ตัวได้เร็ว และทำให้บทเรียนโฟกัส feature drift กับ window strategy ถ้าจะเปรียบเทียบ Random Forest/XGBoost ต้องทำเป็น experiment ชั้นถัดไปด้วย temporal validation เดียวกันIt is an interpretable, fast baseline that keeps the lesson focused on feature drift and window strategy. Random Forest/XGBoost would be a separate experiment under the same temporal validation.

ด่านที่ 1 — เลือก Feature Set ก่อน DeployGate 1 — feature-set selection before deployment

ฝึกบน Jan–Sep 2012 และตัดสินบน Oct–Dec 2012 ซึ่งมาทีหลังตามเวลาTrain on Jan–Sep 2012; decide on the later Oct–Dec 2012 validation period.

Logistic RegressionAccuracyBalanced Acc.F1ROC-AUCผลResult
Raw features0.4930.5260.3460.519—
Engineered features0.7760.7550.5930.829SELECTED ✓

จึงเลือก Logistic Regression + engineered features เป็น v001 แล้ว refit ด้วยข้อมูล Jan–Dec 2012 ก่อนเริ่ม simulation ปี 2013Therefore v001 is Logistic Regression with engineered features, refit on Jan–Dec 2012 before the 2013 simulation begins.

ด่านที่ 2 — เมื่อ Drift trigger: Window ไหนชนะ และเปลี่ยนโมเดลหรือไม่?Gate 2 — after a drift trigger: which window wins, and do we deploy it?

ทุกแถวด้านล่างยังเป็น Logistic Regression + engineered features เหมือนกัน ต่างกันเฉพาะ training window ผู้ชนะเลือกจาก F1 ก่อน แล้วใช้ Balanced Accuracy และ ROC-AUC เป็นตัวแก้เสมอ การ Promote ต้องผ่านทั้ง ΔF1 ≥ +0.020, Balanced Accuracy ลดไม่เกิน 0.010 และมี positive examples อย่างน้อย 100 ตัวอย่างEvery row below is the same Logistic Regression plus engineered features; only the training window changes. Winner ranking uses F1, then Balanced Accuracy and ROC-AUC as tie-breakers. Promotion requires ΔF1 ≥ +0.020, no more than 0.010 Balanced Accuracy regression, and at least 100 positive examples.

เดือนประเมินEvaluation monthChampionChallenger ที่ชนะBest ChallengerChampion F1Winner F1ΔF1การตัดสินใจDecision
2013-07v001 · Initial 2012Rolling 12M0.7820.789+0.0067KEEP
2013-11v001 · Initial 2012Expanding0.7490.772+0.0233PROMOTE → v002
2014-04v002 · ExpandingRolling 12M0.8060.807+0.0016KEEP
2014-10v002 · ExpandingExpanding0.8240.827+0.0027KEEP
คำตอบของ lab: เลือก engineered features ตั้งแต่ design gate และสุดท้ายเปลี่ยนจาก v001 เป็น v002 ที่ใช้ Expanding window ในเดือน 2013-11 เพียงครั้งเดียว Seasonal-2Y และ Hybrid สำคัญในฐานะ hypothesis ที่ต้องทดสอบ แต่ไม่ได้ชนะจากข้อมูลชุดนี้Lab conclusion: engineered features win the design gate, and only once—November 2013—the system replaces v001 with v002 trained on an Expanding window. Seasonal-2Y and Hybrid are valuable hypotheses to test, but they do not win on this dataset.

EDA แบบ Time-lapseEDA time-lapse

Seasonal-2Y referencePrevious monthCurrent month
1 กลุ่มบนแกน X = 1 ช่วงค่าของ feature (bin) · bar 3 สีใช้ขอบ bin เดียวกัน · ความสูงของ bar = สัดส่วน client-day ใน bin นั้น (%) ไม่ใช่จำนวน HIGH/LOW ของ target; เฉพาะ Previous HIGH เท่านั้นที่เป็น feature แบบ LOW (0) / HIGH (1)One X-axis cluster is one feature-value bin. All three bars share the same bin boundaries. Bar height is the percentage of client-day rows in that bin—not the target HIGH/LOW count; only Previous HIGH is a binary feature, LOW (0) / HIGH (1).
—PSI ———
Feature drift แสดงว่า P(X) เปลี่ยน แต่ยังไม่พิสูจน์ว่า P(Y|X) หรือ concept เปลี่ยนFeature drift shows that P(X) changed; it does not prove that P(Y|X), the concept, changed.

ประสิทธิภาพ Champion ตามเวลาChampion performance over time

F1Balanced AccuracyPromotion

สิ่งที่ Airflow อ่านWhat Airflow reads

เหตุการณ์สำคัญMeaningful events