Velamuvi AIAcademy

Lesson 4 of 13 · What Is ML?

Where ML Is Used

How machine learning is used in healthcare, finance, shopping, transport and farming, a tiny recommender in Python, and four signs a problem suits ML.

  • 5 min read
  • Beginner
  • Reviewed
In this lesson you will learn
  • Give real examples of machine learning across different industries
  • Build a tiny recommendation system from purchase history
  • Use four questions to judge whether a problem suits machine learning
  • Recognise problems where machine learning is the wrong tool

Machine learning all around you

AreaExampleType
HealthcareSpotting signs of disease in scans, to help doctors prioritiseClassification
FinanceFlagging card payments that look like fraudClassification
Shopping“Customers who bought this also bought…”Recommendation
TransportPredicting journey times from live trafficRegression
EnergyForecasting electricity demand for tomorrowRegression
FarmingDetecting crop disease from drone photosClassification
Customer serviceRouting emails to the right teamClassification
LanguageTranslation, speech recognition, chat assistantsDeep learning

Build a tiny recommender

Recommendation systems learn from what people did. The simplest version counts which items appear together in the same basket:

Try it yourselfPython
# "Customers who bought this also bought...": learning from purchase history
baskets = [
    {"tent", "sleeping bag", "torch"},
    {"tent", "sleeping bag"},
    {"torch", "batteries"},
    {"tent", "torch", "batteries"},
    {"sleeping bag", "pillow"},
    {"tent", "sleeping bag", "pillow"},
]

def also_bought(item):
    counts = {}
    for basket in baskets:
        if item in basket:
            for other in basket - {item}:
                counts[other] = counts.get(other, 0) + 1
    return sorted(counts.items(), key=lambda pair: (-pair[1], pair[0]))

for item in ["tent", "torch"]:
    bought_with = also_bought(item)
    print(f"People who bought a {item} also bought:", ", ".join(f"{name} ({n})" for name, n in bought_with))

Nobody wrote a rule saying “tents go with sleeping bags”. The pattern came from the data, and it would update by itself as more people shop. Real recommenders use millions of baskets and smarter methods, but the core idea is the same.

Is it a good machine learning problem?

Ask four questions:

  1. Is there a pattern? Past data must say something about the future. Lottery numbers have no pattern; house prices do.
  2. Is there enough data? For supervised learning, you need many examples with the right answers.
  3. Are mistakes acceptable? Every model is sometimes wrong. A wrong film suggestion costs nothing; a wrong medical decision needs a doctor to check.
  4. Is it hard to write the rules by hand? If you can write a clear rule (“orders over 50 euros ship free”), write it. Machine learning is for patterns too complex or changing too fast to write down.

Common mistakes

Practice exercise

Recommendation systems start by counting which items are bought together. Count one pair.

Your solutionPython
baskets = [
    {"tent", "sleeping bag", "torch"},
    {"tent", "sleeping bag"},
    {"torch", "batteries"},
    {"tent", "torch", "batteries"},
]

# How many baskets contain BOTH "torch" and "batteries"? Print just the number.
Knowledge check

Which problem is the WORST fit for machine learning?

Summary

  • Machine learning is used in healthcare, finance, shopping, transport, energy, farming and more.
  • A simple recommender can learn from which items are bought together.
  • Good ML problems have a pattern, enough data, acceptable mistakes, and rules that are hard to write by hand.
  • Start from the goal, not the technology, and take extra care where decisions affect people.

Next: features and labels, the building blocks of every dataset.

Finished reading? Tick it off to track your progress.