TGViewer
Machine Learning with Python Machine Learning with Python @codeprogrammer · 68.5K subscribers
Post #5062 4.07K
Overfitting and Generalisation in ML.pdf380.5 KB
Overfitting and Generalization in Machine Learning

My ML model had 100% accuracy.
And was completely useless.

That's not a paradox; that's overfitting.

The model didn't learn. It memorized.

Here's the mathematical core most tutorials skip:

E[loss] = Bias² + Variance + σ²

→ Bias² = too simple → Underfitting
→ Variance = too complex → Overfitting
→ σ² = irreducible → always there

What this actually means in practice:

→ A degree-9 polynomial on 6 data points hits R² = 1.0 and oscillates wildly between them
→ A linear model on sine-wave data has near-zero variance — but massive bias
→ The optimal model isn't the simplest. Not the most complex. It's the one minimizing Bias² + Variance

And the generalization gap?

Formally defined as:
gen_gap(f) = R(f) − R_emp(f)

When this value is ≫ 0, your model is learning noise, not signal.

The fix isn't "collect more data and hope."
The fix is regularization, which I derive fully in my paper: L1, L2, Dropout, and Early Stopping, all from first principles.

Which regularization strategy do you use most and why?

https://t.me/CodeProgrammer
  • ❤ 9
  • 🔥 1
  • 💯 1
More from @codeprogrammer
  1. Oct 7, 2026Post #5563
  2. Oct 7, 2026A distinctive bot for subscribing to courses on the most popular educational platforms acr…
  3. Oct 7, 2026Understanding algorithms changes the way you write code. 🧠 This playlist teaches you exac…
  4. Oct 6, 2026🛠 Built an AI app with Cursor, Claude Code or Lovable? Publish it on Zibby (zibby.run), a…
  5. Oct 5, 2026🚀 ChatGPT Plus & Gemini AI Pro🤖 ChatGPT Plus — 1 Month: $8 ✨ Gemini AI Pro — 18 Months:…
  6. Oct 4, 2026I found a great resource for interactive learning about machine learning and AI – VizLearn…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →