Before you start
What this module changes in your trading process.
Explain why random k-fold validation is invalid for time series.
Wrong validation is the fastest way to fool yourself with ML. Learn validation techniques specific to financial time series.
Module outline
Before you start
Explain why random k-fold validation is invalid for time series.
Lesson 1
Menjelaskan mengapa k-fold acak tidak valid untuk deret waktu.
Cross-validation k-fold standar mengacak data ke beberapa lipatan. Untuk data biasa itu baik — tetapi untuk deret waktu ini bencana: • Pengacakan menaruh data masa depan ke set latih dan masa lalu ke set uji — model "belajar dari masa depan" (look-ahead). • Observasi finansial berkorelasi temporal (hari berdekatan mirip), sehingga sampel latih & uji yang bertetangga saling bocor.
Akibatnya K-fold acak menghasilkan skor validasi yang tampak hebat tetapi runtuh saat live. Inilah salah satu kesalahan paling umum pemula ML di trading. Solusi: validasi yang menghormati urutan waktu .
Example
Practical example: K-fold acak membocorkan masa depan ke pelatihan pada deret waktu.
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Lesson 2
Menerapkan walk-forward validation dan time-series split.
Pendekatan yang benar selalu melatih pada masa lalu dan menguji pada masa depan, lalu menggeser maju.
Example code: from sklearn.model_selection import TimeSeriesSplit tscv = TimeSeriesSplit(n_splits=5) for train_idx, test_idx in tscv.split(X): # train_idx selalu lebih awal dari test_idx Xtr, Xte = X.iloc[train_idx], X.iloc[test_idx] ytr, yte = y.iloc[train_idx], y.iloc[test_idx] model.fit(Xtr, ytr) score = evaluate(model, Xte, yte) • Expanding window: data latih membesar tiap langkah (akumulasi sejarah). • Rolling window: jendela latih berukuran tetap bergeser maju (lebih adaptif pada perubahan rezim).
Walk-forward menghasilkan banyak periode uji out-of-sample berurutan, memberi gambaran realistis kinerja sepanjang waktu — bukan satu kebetulan.
Example
from sklearn.model_selection import TimeSeriesSplit tscv = TimeSeriesSplit(n_splits=5) for train_idx, test_idx in tscv.split(X): # train_idx selalu lebih awal dari test_idx Xtr, Xte = X.iloc[train_idx], X.iloc[test_idx] ytr, yte = y.iloc[train_idx], y.iloc[test_idx] model.fit(Xtr, ytr) score = evaluate(model, Xte, yte)
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Lesson 3
Memahami purged k-fold dan embargo untuk mencegah kebocoran antar-sampel.
Bahkan dengan split temporal, kebocoran halus bisa terjadi bila label menjangkau beberapa periode (mis. label = return 5 hari ke depan). Sampel di batas latih/uji bisa tumpang tindih waktunya. • Purging: hapus sampel latih yang jendela labelnya tumpang tindih dengan periode uji. • Embargo: beri jeda (gap) setelah set uji sebelum melanjutkan set latih, agar autokorelasi tidak membocorkan informasi.
Teknik purged k-fold dengan embargo (dipopulerkan oleh literatur quant modern) adalah standar emas validasi ML finansial saat label tumpang tindih. Feature importance: hati-hati Model memberi skor "pentingnya fitur", tetapi: importance bisa menyesatkan saat fitur berkorelasi, dan fitur "penting" pada masa lalu bisa tidak relevan di masa depan. Gunakan importance sebagai petunjuk eksplorasi, bukan kebenaran final.
Utamakan fitur yang punya alasan ekonomi. Disiplin yang sama Semua pelajaran dari QUANT 206 berlaku: sampel memadai, waspadai multiple testing, dan utamakan hipotesis beralasan. ML memperbesar daya — sekaligus memperbesar risiko menipu diri sendiri.
Example
Practical example: Purging membuang sampel latih yang labelnya tumpang tindih dengan periode uji.
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Fieldwork
Build one worksheet for Correct ML Validation for Time Series: state the market, the rule, the data input, the risk limit, the validation check, and the review note before using it live.
Glossary
Checkpoint quiz
Quiz results can add XP when you are signed in.
Progress action
Marking complete saves the module, updates streak activity, and awards XP only once per module.
Previous module
Machine learning is a tool, not magic. Frame market prediction as supervised learning and build the right conceptual pipeline.
Next module
Apply statistical foundations to practical quant strategies including mean reversion, pairs trading, cross-sectional momentum, and factor investing.
Risk note: Metavulus learning content is for education and market preparation only. It is not financial advice, investment advice, or a trading recommendation.