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.
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.
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.
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:
- The workflow, the train/test split, the scikit-learn API and baselines.
- Regression on a medical dataset, with the loss function and gradient descent pictured.
- Classification on churn: logistic regression, trees, ensembles, and the metrics that matter.
- The habits that keep you honest: cross-validation, pipelines, tuning, leakage.
- 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.