FoundationsCore· 25 min read

What is Machine Learning?

Instead of writing every rule by hand, you let a program learn the rule from examples.

What you will learn

  • Define machine learning in plain words
  • Tell learning from data apart from writing rules
  • Spot ML you already use every day

Two ways to make a computer smart

Normally you program a computer by writing rules yourself: if this, then that. Machine learning (ML) flips that around. You show the computer lots of examples, and it figures out the rule on its own.

Think of a spam filter. The old way is to hand-write rules like if the email says “free money”, mark it as spam — but spammers just change the words. The ML way is to show the computer thousands of emails already labelled spam or not spam, and let it learn what spam looks like by itself.

Rules vs learning, side by side

Writing rulesMachine learning
Who makes the ruleYou, by handThe computer, from data
Needs examples?NoYes — lots of them
Handles messy real dataBadlyWell
Improves over timeOnly if you edit itYes, with more data

Seeing it as code

Here is the same job — is this email spam? — written both ways, so the difference is clear.

Left: a hand-written rule. Right (in comments): what ML does instead
# The old way: a rule YOU write
def is_spam(email):
    return 'free money' in email.lower()

# The ML way (in spirit): the computer learns the rule from examples
# emails  -> ['win cash now', 'lunch at 1pm', 'free money here', ...]
# labels  -> ['spam',         'not spam',     'spam',            ...]
# A model studies these and predicts the label for a NEW email.
print(is_spam('Claim your FREE MONEY now'))
print(is_spam('Are we still on for lunch?'))

Note: Output: True False The hand-written rule only catches the exact words you thought of. A trained model learns the broader pattern from many labelled emails — including tricks you never anticipated.

You already learn from data

Here is the key idea in a tiny table. Look at how many hours some students studied and whether they passed. Do not write a rule — just look for the pattern.

Hours studiedResult
1Fail
2Fail
3Fail
5Pass
6Pass
8Pass

Your brain instantly guessed something like “study more than about 4 hours and you pass.” Nobody gave you that rule — you learned it from the examples. That is exactly what a machine-learning model does, only with thousands of rows and numbers instead of six. Notice you also did not need any maths to spot it; the computer just does the same thing at a bigger scale.

ML you already use

  • Netflix and YouTube recommending what to watch next.
  • Your email sorting spam from real mail.
  • Banks spotting a fraudulent card payment.
  • Your phone recognising faces in photos.
  • Shops predicting how much stock to order next month.

Tip: You do not need heavy maths to start. A library (a ready-made bundle of code other people wrote that you can reuse) called scikit-learn does the hard maths for you. It is a free Python toolkit for machine learning — and in code you import it under the short name sklearn, so scikit-learn and sklearn mean the same thing. Your job is to prepare good data and pick the right tool.

Watch out: ML is not magic. If you feed it bad or too little data, it learns the wrong thing. Good data matters more than a fancy algorithm.

Q. What is the key difference between machine learning and ordinary programming?

Answer: In ordinary programming you write the rules. In machine learning you supply labelled examples and the computer discovers the rule itself.

✍️ Practice

  1. List five apps you used today and guess where each one uses machine learning.
  2. Write a hand-written is_spam() rule, then explain one email it would get wrong.

🏠 Homework

  1. In 3–4 sentences, explain to a non-technical friend what machine learning is, using your own everyday example.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →