Maan lo hum degree d ke polynomial se stock returns predict kar rahe hain:
y^=β0+β1x+β2x2+…+βdxd
Yeh overfitting KYUN demonstrate karta hai: Jaise jaise d badhta hai, model training data ko perfectly fit kar sakta hai, lekin test error explode ho jaata hai.
Mathematically HOW dekhen:
n data points aur degree d=n−1 ke saath, polynomial har point se exactly pass hota hai (Lagrange interpolation). Training error = 0, lekin points ke beech mein polynomial wildly oscillate karta hai.
Degrees of freedom: Effective number of parameters. Polynomial degree d ke liye, DoF = d+1. Rule of thumb: stable estimates ke liye n≥10×DoF chahiye.
Agar yeh ratio > 0.2 (20% degradation) ho, toh likely overfit hai.
Cross-Validation:
K-Fold: Data ko K chunks mein split karo, K-1 pe train karo, 1 pe test karo, K baar repeat karo
Time-series CV: Expanding ya sliding window use karo (temporal order preserve karo)
Yeh KYUN kaam karta hai: K alag test sets pe simultaneously overfit karna mushkil hai. Folds mein high variance = unstable model.
Learning Curves:
Training error aur validation error ko training set size ke against plot karo
Converging curves (large N pe chhota gap): Achha generalization
Diverging curves (widening gap): Overfitting
HOW interpret karein: Agar zyada data add karne se gap close hota hai, toh zyada data collect karo. Agar gap persist kare, toh model simplify karo.
Permutation Test:
Target variable ko randomly shuffle karo (koi bhi real relationship destroy karo)
Poora optimization process dobara chalao
Agar shuffled data pe "optimized" strategy abhi bhi achhi lagti hai, tumhara process noise ko curve-fit kar raha hai
Yeh KYUN powerful hai: Random data mein koi signal nahi hota. Koi bhi found edge = tumhari methodology se false positive.
Pehle simplicity: Simple model se shuru karo (linear regression, 2-3 features). Complexity sirf tabhi add karo jab theory aur out-of-sample improvement se justified ho.
Feature engineering over feature dumping: 5 carefully chosen features 100 raw indicators se behtar hain.
Economic reasoning: Har parameter ka financial explanation hona chahiye. "23-day MA cross kare 47-day MA ko jab buy karo" ka koi theoretical basis nahi—kyun 22 aur 46 nahi?
Walk-forward analysis:
Year 1 pe train karo, Year 2 pe test karo
Year 1-2 pe retrain karo, Year 3 pe test karo
Rolling forward continue karo
KYUN: Real trading simulate karta hai jahan tum periodically naye data ke saath retrain karte ho
Robust optimization: Single best parameter set chunne ki jagah, woh chunno jo nearby parameters ki ek range mein kaafi achha perform kare. Agar performance chhote changes ke liye sensitive hai (jaise MA period 14 vs. 15 completely results change kar de), strategy fragile hai.
Information coefficient (IC): Predictive models ke liye, predictions aur actual outcomes ke beech rank correlation measure karo:
IC=cor(predicted returns,actual returns)
IC time periods mein stable rehna chahiye. Declining IC = strategy decay ya overfitting.
Sample size rules:
Minimum: n>10p jahan p = number of parameters
Conservative: n>30p
Rare events ke liye (jaise crashes predict karna): Hundreds of occurrences chahiye
Recall 12 saal ke bachche ko explain karo
Imagine karo tum apne dost ki handwriting pehchanna seekh rahe ho. Tumhara dost tumhe 20 words dikhata hai jo usne likhe hain. Tum un 20 specific words ko exactly memorize kar sakte ho—har choti wiggle aur dot. Lekin yeh silly hai! Kyunki agli baar jab woh "hello" likhega, woh exactly same nahi lagega. Shayad 'e' thoda gol ho. Agar tumne zyada perfectly memorize kiya, toh tum use pehchan nahi paoge.
Smart tarika yeh hai ki general style seekho: "Oh, woh apna 'h' normal se zyada lamba banata hai aur letters smoothly connect karta hai." Ab tum unki handwriting un naye words mein bhi pehchan sakte ho jo tumne unhe pehle likhte nahi dekha.
Stock trading mein, overfitting waise hai jaise un exact 20 words ko memorize karna general style seekhne ki jagah. Tumhara computer strategy purane stock prices dekhta hai aur seekhta hai "June 5th 2018 ko jab price exactly $34.27 tha, woh upar gaya!" Lekin woh exact situation kabhi dobara nahi hogi. Strategy naye data pe fail hoti hai kyunki usne history ki details memorize ki real patterns seekhne ki jagah.
Fix? Apni strategy simple rakho. Ise us data pe test karo jo tumhare computer ne kabhi nahi dekha (jaise surprise quiz!). Aur hamesha poocho "Yeh KYUN kaam karega?" na ki sirf "Kya yeh past mein kaam kiya?"
Ek model ke effective degrees of freedom woh independent parameters ki sankhya hai jo estimate ki ja rahi hain. Trading strategies ke liye:
DoF=# explicit parameters+# implicit choices
Explicit: MA periods, threshold values, position sizes
Implicit: Kaun se features include karein, kaun sa optimization metric use karein, backtest kab start/stop karein
Yeh KYUN matter karta hai: Statistical tests degrees of freedom assume karte hain. Agar tum claim karo "Meri strategy ka t-statistic 3.5 hai, p < 0.001 pe significant hai," lekin tumne secretly 100 variations try kiye, toh actual p-value bahut zyada hai.
Bonferroni correction: Agar tum m independent tests chalate ho, significance level adjust karo:
αcorrected=mα
Agar tum overall 5% significance chahte ho aur 100 tests chalate ho: αcorrected=0.05/100=0.005. Ab tumhe 1.96 ki jagah ~3.5 ka t-statistic chahiye.
Machine-learning-in-trading - ML models ki high capacity hoti hai, isliye strong overfitting prevention zaroori hai
#flashcards/stock-market
Overfitting trading mein kya hoti hai? :: Jab model historical data mein noise aur random fluctuations seekh leta hai na ki true signal, jisse backtest performance achhi hoti hai lekin live performance kharab.
Bias-variance tradeoff kya hai?
Total error = Bias² + Variance + Irreducible error. Complex models mein low bias lekin high variance hota hai; simple models mein high bias lekin low variance. Balance karna zaroori hai.
Multiple testing overfitting KYUN cause karta hai?
Kaafi parameter combinations test karne ka matlab hai kuch pure luck se achhe lagenge. 5% significance pe 100 tests ke saath, kam se kam ek false positive ki probability 100% ke paas pahunch jaati hai.
Walk-forward analysis kya hai?
Period 1 pe train karo, Period 2 pe test karo, Period 1-2 pe retrain karo, Period 3 pe test karo, rolling forward. Real trading simulate karta hai periodic retraining ke saath aur future information use hone se rokta hai.
Sample size vs parameters ke liye rule of thumb kya hai?
Minimum n > 10p observations chahiye, jahan p parameters ki sankhya hai. Conservative standard n > 30p hai. Rare events ke liye hundreds of occurrences chahiye.
Curve fitting kya hai?
Model parameters ko baar baar adjust karna test results dekhte hue jab tak performance achhi na lage. Test set contaminate hota hai kyunki tum development guide karne ke liye us se information use kar rahe ho.
Regularization kya hai?
Loss function mein penalty term add karna model complexity discourage karne ke liye. L1 (Lasso) feature selection ke liye kuch coefficients ko zero force karta hai. L2 (Ridge) smoother fit ke liye sab coefficients shrink karta hai.
Overfitting HOW detect karte hain? :: Train vs test performance compare karo (>20% degradation warning hai), k-fold cross-validation use karo (folds mein high variance = unstable model), learning curves plot karo (diverging curves), shuffled data pe permutation tests chalao.
Overfitting ke liye permutation test kya hai?
Target variable ko randomly shuffle karo real relationships destroy karne ke liye, phir poora optimization process dobara chalao. Agar random data pe bhi results achhe lagte hain, tumhara process noise ko curve-fit kar raha hai.
Zyada data overfitting KYUN hamesha nahi rokta? :: Markets mein regime changes aur non-stationarity hoti hai. Alag regimes ke purane data se zyada nuksan ho sakta hai. Current regime ka 1 saal data multiple alag regimes spanning 10 saal se behtar hai.
Bonferroni correction kya hai?
m independent tests chalane pe, significance level ko α/m pe adjust karo. 100 parameter combinations 5% overall significance pe test karne mein, har individual test ko 0.05/100 = 0.0005 significance chahiye.
Effective degrees of freedom kya hain?
Explicit parameters (MA periods, thresholds) aur implicit choices (kaun se features test karein, kaun sa metric optimize karein, date range selection) dono ki total count. Sab multiple testing problem mein count hote hain.
Robust optimization kya hai?
Single best ki jagah aas paas ki values ki range mein kaafi achha perform karne wala parameter set chunna. Agar chhote parameter changes se results drastically badal jaate hain, strategy fragile aur overfit hai.
Information coefficient kya hai?
Predicted returns aur actual returns ke beech rank correlation: IC = corr(predictions, outcomes). Time periods mein stable rehna chahiye. Declining IC strategy decay ya overfitting indicate karta hai.
Parsimonious model kya hota hai?
Woh simplest model jo data ko adequately explain kare. Har parameter ka economic justification hona chahiye. 100 data-mined indicators se behtar hain 3 theoretically-motivated features.