Stop 01 · Machine Learning FoundationsTopics · 1/10

What Machine Learning Is (and Isn't)

Part of the Machine Learning Roadmap

In short

Normal programs follow rules a person wrote. Machine learning flips that: you show the computer lots of examples with answers, and it works out the rules by itself. Knowing when that helps, and when it doesn't, is the first real ML skill.

Machine learning builds programs that learn patterns from examples instead of following hand-written rules. It shines when you have plenty of relevant data and a clear target, and it is the wrong tool when a simple rule works or the data is tiny or biased.

The jaadu squeezes and sniffs mangoes at a busy market stall, sorting them into a ripe basket and an unripe basket.

Think of it like this

Nani picking mangoes

Ask your nani how she picks ripe mangoes and she can't write you a rulebook. She has simply squeezed and sniffed thousands of them, and her hands learned the pattern. ML learns the same way: from many examples, not from a rule someone typed. But if the rule is simple, like 'stickers marked A are export quality', you don't need nani's years of practice. You just read the sticker.

Watch it happen

Hand-written rules vs a learned model

Traditional program

  • A person writes the rules: if softness > 6 and smell > 5, it's ripe.
  • Works well when the rule is simple and stable.
  • Breaks when the pattern is fuzzy or keeps changing.

Machine learning

  • You give examples with answers: 1,000 mangoes marked ripe or not.
  • The algorithm finds the rule that best fits those examples.
  • Needs enough good data, and can only be as fair as that data.

Use ML when the pattern is too fuzzy to write down but you have plenty of labelled examples. If a simple rule works, use the rule.

The big ideas

What you need to know

Data in, rules out

A program takes rules plus data and gives answers. ML takes data plus answers and gives you the rules, called a model.

It needs a clear target

You must say exactly what to predict: ripe or not, price in rupees, spam or not. A vague goal gives a useless model.

It is not magic

A model only knows patterns in its training data. Tiny, wrong or biased data gives tiny, wrong or biased predictions.

Sometimes a rule wins

Checking if a PIN code has six digits needs one line of code, not a model. ML is for patterns you can't easily spell out.

See it in code

Walk through the code

python
1from sklearn.tree import DecisionTreeClassifier2 3# Traditional: a person writes the logic4def is_ripe_rule(softness, smell):5    return softness > 6 and smell > 56 7# ML: the model learns the logic from examples8X = [[8, 7], [3, 2], [7, 8], [2, 4], [9, 6], [4, 3]]  # softness, smell (1-10)9y = [1, 0, 1, 0, 1, 0]                                 # 1 = ripe, 0 = not ripe10 11model = DecisionTreeClassifier(random_state=0)12model.fit(X, y)13 14print(is_ripe_rule(7, 6))        # True15print(model.predict([[7, 6]]))   # [1]

1/4The classic approach: a human decides the thresholds.

The same question answered two ways. The rule was typed by a person. The tree found its own rule from six labelled mangoes.

Save yourself the pain

Common mistakes

Oops

Reaching for ML for every problem because it sounds impressive.

Do this instead

First ask if a simple rule or a SQL query solves it. Use ML only when the pattern is too complex to write by hand.

Oops

Believing the model 'understands' the problem.

Do this instead

It only finds statistical patterns in the data you gave it. If the data changes, its answers can quietly go wrong.

Oops

Starting with an algorithm before defining the target.

Do this instead

Write one sentence first: 'Given X, predict Y, so that we can do Z.' Then collect data that matches it.

Your mission

ML or not?

~15 min

Quick check

Which problem is the best fit for machine learning?

Go deeper

  1. 1Write down three everyday problems and decide whether each needs ML or a plain if-else rule.
  2. 2Watch the first lecture of Andrew Ng's Machine Learning Specialization on Coursera.
  3. 3For one problem that does need ML, list the examples and the target you would need to collect.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge