MACHINE LEARNING • LESSON 1 • FOUNDATIONS

Why Do We Need Machine Learning?

Computers are excellent at following instructions. But some real-world problems are difficult to solve by writing every possible rule manually.

The important question is not: "Can a computer follow rules?"

Of course it can.

The real question is: "Can we write all the useful rules?"

Some Problems Are Easy to Solve With Rules

Consider a simple problem: we want to know whether a number is even or odd.

We can write a clear rule:

if number % 2 == 0:
    result = "Even"
else:
    result = "Odd"

There is no need for Machine Learning here.

The rule is simple, clear, and reliable.

SIMPLE PROBLEM If a problem can be solved with a small number of reliable rules, traditional programming is usually the better choice.

But Some Problems Are Much More Complicated

Now imagine that we want a computer to identify whether an email is spam.

We might start with rules such as:

Rule 1

If the email contains "FREE", mark it as spam.

Rule 2

If the email contains many links, mark it as spam.

Rule 3

If the sender is unknown, mark it as spam.

But these rules create problems.

A legitimate email can contain the word "FREE". A real company can send an email containing many links. And an important email can come from someone we have never contacted before.

We would need to keep adding more and more rules.

THE PROBLEM The number of possible situations becomes too large for humans to describe with simple rules.

Real-World Problems Keep Changing

There is another problem with manually written rules: real-world data changes.

Imagine a spam filter that was created using rules written five years ago.

Spammers can change:

  • The words they use.
  • The links they send.
  • The way they format messages.
  • The addresses they use.

If the system depends entirely on manually written rules, programmers may have to keep updating those rules whenever the behavior changes.

Machine Learning gives us another approach.

Instead of manually describing every possible pattern, we can provide examples and allow an algorithm to learn useful patterns from the data.

Example: Recognizing Objects in Images

Consider another problem:

Can we write rules that identify every cat in every photograph?

We could try.

We might say a cat has:

  • Two eyes.
  • Two ears.
  • Fur.
  • A particular body shape.

But photographs can look very different.

A cat can be sitting, standing, lying down, partially hidden, far away, in darkness, or viewed from a completely different angle.

Trying to write a rule for every possible image quickly becomes impractical.

TRADITIONAL APPROACH

Write the Rules

Humans try to describe every important situation with explicit instructions.

MACHINE LEARNING

Learn From Examples

Give the system many examples and let an algorithm find useful patterns in the data.

What Changes With Machine Learning?

In traditional programming, humans explicitly write the rules.

INPUT Data
+
HUMAN Rules
RESULT Output

With Machine Learning, the approach changes.

EXAMPLES Data + Answers
LEARNING Find Patterns
RESULT Model

The important change is that we are no longer trying to manually write every rule.

When Is Machine Learning Useful?

Machine Learning becomes useful when the problem has patterns that are difficult to describe with fixed rules.

Many Possible Patterns

There may be too many combinations for humans to describe manually.

Complex Relationships

Several pieces of information may interact in ways that are difficult to express as rules.

Large Amounts of Data

A system can learn from large collections of examples.

Changing Patterns

The patterns in the real world may change over time.

Machine Learning Does Not Magically Solve the Problem

This is an important point for beginners.

Machine Learning does not mean we give a computer completely random data and it automatically understands everything.

We still need humans to decide:

  • What problem are we trying to solve?
  • What data should we collect?
  • What information is useful?
  • What should the model predict?
  • How will we know whether the prediction is good?
Machine Learning is a tool, not magic.

A model can only learn useful patterns from the information and examples we provide.

Do We Always Need Machine Learning?

No.

This is something beginners often misunderstand. Machine Learning is not automatically better than traditional programming.

Problem Better Approach
Calculate a tax using known rules Traditional Programming
Predict whether an email is spam Machine Learning may help
Calculate 10% discount Traditional Programming
Predict house prices from many factors Machine Learning may help
Use Machine Learning because the problem needs it, not because it sounds more advanced.

Now Let's Use a Simple Real-World Problem

We now understand why Machine Learning can be useful.

But we need to see the idea in action.

So let's take a problem that is easy enough to understand but realistic enough to demonstrate the basic Machine Learning idea.

OUR FIRST PROBLEM

House Price Prediction

Can we look at examples of houses and their prices, find a relationship between them, and use that relationship to predict the price of a new house?

KEY TAKEAWAY

We need Machine Learning when writing all the rules manually becomes difficult.

Traditional programming is excellent when the rules are clear and manageable. Machine Learning becomes useful when a problem contains complex or changing patterns that are difficult to describe with fixed instructions.