DEV Community

Cover image for Day 4 : How Machines Learn From Their Mistakes
Chanchal Singh
Chanchal Singh

Posted on

Day 4 : How Machines Learn From Their Mistakes

Imagine you are standing on a hill at night 🌙.
It’s dark. Fog everywhere.

Your goal?

Reach the lowest point of the hill.

But there’s a problem:

  • You can’t see the whole hill
  • You can only see one step ahead

So what do you do?

You take a small step downwards.
Then another.
Then another.

Slowly… you reach the bottom.

That is Gradient Descent.

Gradient Descent 3D Graph

What Problem Is Gradient Descent Solving?

From Day 3, we learned:

  • Every model makes mistakes
  • Those mistakes are measured using loss

Now the big question is:

How does the model reduce this loss?

Answer:

By slowly adjusting itself in the right direction.

That adjustment process is called Gradient Descent.


Think Like the Model 🧠

The model keeps asking:

  • “Am I too high?”
  • “Am I too low?”
  • “Which direction reduces my mistake?”

Then it moves step by step to reduce loss.

Not randomly.
Not all at once.
Slowly and carefully.


What Is Actually Moving?

Remember the straight line from Day 2?


That line depends on:
  • Coefficients
  • Intercept

Gradient Descent:

  • Tweaks these values
  • Checks loss again
  • Tweaks again

Until loss becomes as small as possible.


Learning Rate: Size of the Step 👣

Now comes an important choice.

How big should each step be?

That choice is called learning rate.


If the learning rate is too big 🚀

You jump too far.

  • Miss the bottom
  • Bounce around
  • Never settle

Like jumping down stairs instead of walking.


If the learning rate is too small 🐢

You move very slowly.

  • You’ll reach the bottom
  • But it’ll take forever

Like taking baby steps on a long road.


📌 Good learning rate = steady, confident steps


Why Feature Scaling Matters Here

Imagine walking downhill:

  • One step forward = 1 meter
  • One step sideways = 1 kilometer

Movement becomes awkward.

Same with data.

If one feature is very large and another is very small:

  • Gradient Descent struggles
  • Learning becomes slow or unstable

Feature scaling makes all features:

Speak the same language


When Gradient Descent Stops

Gradient Descent stops when:

  • Loss stops decreasing
  • Model is no longer improving

That point is called:

Minimum loss

That’s the “bottom of the hill”.


Tiny Thought Experiment 🧠

Trying to lose weight:

  • Sudden extreme dieting ❌
  • Slow, consistent effort ✅

Gradient Descent believes in consistency, not shortcuts.


3-Line Takeaway

  • Gradient Descent reduces loss step by step
  • Learning rate controls step size
  • Feature scaling helps learning move smoothly

What’s Coming Next 👀

Now the question becomes:

How do we know if the model we trained is actually good?

That’s where evaluation metrics come in.

👉 Day 5 — Is Your Regression Model Any Good? (Evaluation Metrics)

I love breaking down complex topics into simple, easy-to-understand explanations so everyone can follow along. If you're into learning AI in a beginner-friendly way, make sure to follow for more!

Connect on Linkedin: https://www.linkedin.com/in/chanchalsingh22/
Connect on YouTube: https://www.youtube.com/@Brains_Behind_Bots

Top comments (0)