Traditional Programming vs Machine Learning

To understand why Machine Learning is useful, we first need to understand how a normal computer program works.

Traditional Programming

In traditional programming, we give the computer explicit instructions.

For example, suppose we want a program that tells us whether a temperature is hot or not.

Our Rule

If the temperature is greater than 30°C, call it Hot.

We can write that rule ourselves:

if temperature > 30:
    result = "Hot"
else:
    result = "Not Hot"

The computer does not need to learn anything here. We already told it exactly what to do.

Temperature + Our Rule Answer

But What If the Rules Are Difficult?

Now consider a completely different problem:

Can we write simple rules that identify every spam email?

We could start with rules such as:

  • If the email contains "FREE", maybe it is spam.
  • If it contains many links, maybe it is spam.
  • If the sender is unknown, maybe it is spam.

But these rules are not enough.

A legitimate email might contain the word "FREE". A real company might send an email containing several links. A genuine email might also come from a sender we don't know.

We would need to keep adding more and more rules.

This Is Where Machine Learning Helps

Instead of trying to write every rule ourselves, we can give the computer examples where we already know the answer.

Email Example Known Answer
"Win FREE money now!" Spam
"Your meeting is at 3 PM." Not Spam
"Claim your prize today." Spam
"Project report attached." Not Spam

The idea is no longer:

"Here are all the rules."

Instead, we are saying:

"Here are many examples. Find useful patterns."

The Core Difference

Traditional Programming

We know the rules and write them ourselves.

Data + Rules Program

Machine Learning

We provide examples and the algorithm learns a useful relationship from them.

Data + Examples Model
Important:

Machine Learning does not mean that the computer magically understands the problem.

We still need to decide what problem to solve, what data to use, and what we want the model to predict.

Now that we understand the difference, the next question is:

Why do we actually need Machine Learning? Let's look at a problem where writing rules manually becomes difficult.