EduFlow

Section 1 · What Machine Learning Is

Learning from Examples

14 min3 min readChoose wisely

Lesson at a glance

Explain what machine learning does differently from hand-written rules, tell supervised from unsupervised problems, and describe the churn question this course answers.

  1. 1Rules from examples
  2. 2Kinds of learning
  3. 3How this course works

No video here — just the real thing: a written lesson, runnable examples, a quiz and practice.

Cartwheel, the online store you will work with in this course, has a problem every subscription-free shop has. Customers drift away without saying goodbye. Nobody cancels anything; they stop ordering. The marketing team wants to send a win-back offer to customers who are about to go quiet, before they are gone. Which customers?

You could write a rule: “if a customer hasn’t ordered in 90 days, send the offer”. That rule is a fine start, and you will measure it properly in a later lesson. But churn depends on more than one number. A customer with fifteen orders who went quiet for a month is different from a one-time buyer who went quiet for a month. Writing rules for every combination of tenure, order count, spend, coupons and support tickets gets out of hand fast.

Rules from examples

Machine learning flips the job around. Instead of writing the rules, you collect examples where you already know the answer, and an algorithm finds a rule that fits them. For Cartwheel, that means past customers, what they looked like on a given date, and whether they ordered again in the following 90 days.

In classic programming, rules and data go in and answers come out. In machine learning, data and known answers go in and a learned rule, the model, comes out. Classic programming Rules Data Answers Machine learning Data Answers Rules (a model)
Classic programming versus machine learning

The learned rule is called a model. Once you have it, you feed it new customers and it predicts their answer. That is the whole idea; the rest of this course is about doing it well and knowing when the predictions deserve trust.

Here is the table you will spend most of the course with. Each row is a customer, each column is something known about them on 30 September 2025, and churned records what happened next.

Python
import pandas as pd

churn = pd.read_csv("churn.csv")
print(churn.shape)
print(churn[["orders", "days_since_last_order", "support_tickets", "churned"]].head())
print("Churn rate:", round(churn["churned"].mean(), 3))

398 customers, 55% of whom did not order again within 90 days. The columns you predict from are the features; the column you predict is the target (or label).

Kinds of learning

Supervised learning has a target column. The examples come with answers, and the model learns to map features to the answer. Two flavours, depending on the target:

  • Classification: the target is a category. Will this customer churn, yes or no? Is this tumour benign or malignant? Which digit is in this image?
  • Regression: the target is a number. How much will this customer spend next year? How far will a disease progress?

Unsupervised learning has no target. You ask the data a looser question: which customers resemble each other? Can thirty columns be summarised by two? You will meet clustering and PCA, the two workhorses, in section 5.

How this course works

You will build everything in scikit-learn, the standard Python library for classic machine learning, and run it in the browser. Each section adds one layer:

  1. The workflow, the train/test split, the scikit-learn API and baselines.
  2. Regression on a medical dataset, with the loss function and gradient descent pictured.
  3. Classification on churn: logistic regression, trees, ensembles, and the metrics that matter.
  4. The habits that keep you honest: cross-validation, pipelines, tuning, leakage.
  5. Clustering, neural networks, where LLMs fit, fairness, and shipping.

One habit runs through all of it. Before you believe a score, you ask “compared to what?”. A model that is 73% accurate sounds good until you learn that guessing “churned” for everyone gets 55%, and a one-line rule gets 72%. Next lesson starts with the most important step in that habit: setting data aside so you can measure honestly.

Key takeaways

  • Machine learning takes examples of inputs with known answers and produces a function that predicts answers for new inputs.
  • Supervised learning needs a labelled target column; unsupervised learning looks for structure in data with no target.
  • Predicting a number is regression; predicting a category is classification.
  • If a short rule or a SQL query answers the question well enough, you do not need a model.

Further reading

Check your understanding

3 questions

Question 1 of 3

Cartwheel wants to group its customers into a few shopping styles, but nobody has labelled any customer with a style. What kind of problem is this?

Question 2 of 3

Which question is a regression problem?

Question 3 of 3

A teammate proposes a model to flag orders over $10,000 for manual review. What is the best response?

Practice

Choose wisely

Which of these are supervised learning problems?

Cartwheel’s teams have pitched five ideas. Select every idea that is a supervised learning problem: one where you have past examples with a known answer and want a model to predict that answer for new cases.

Which of these are supervised learning problems?