Module 11 · Machine Learning: How Models Learn · Lesson 35 of 51
What machine learning really is
Learning from examples, supervised vs unsupervised, regression vs classification, the six-step workflow, train and test sets, and why every model needs a baseline.
In this lesson · about 35 minutes
- Tell supervised from unsupervised learning, and regression from classification
- Describe the workflow from question to deployed model
- Split data into train and test sets and beat a simple baseline
The main kinds
| Kind | You have | The model learns to… | Café example |
|---|---|---|---|
| Supervised: regression | Inputs and a numeric answer | Predict a number | Tomorrow's sales from weather and weekday |
| Supervised: classification | Inputs and a category answer | Predict a class (and a probability) | Will this member churn: yes or no? |
| Unsupervised: clustering | Inputs only, no answer | Find groups | Segments of members with similar habits |
| Unsupervised: anomaly detection | Inputs only | Flag unusual rows | A till with strange refund patterns |
The answer column in supervised learning is called the target or label (often y); the inputs are features (X).
The workflow
- Frame the question: what decision will the prediction change? What counts as good enough?
- Get and clean data (Modules 3–5).
- Engineer features (Module 10).
- Split: training set to learn from, test set locked away to judge at the end.
- Train and compare models against a baseline.
- Evaluate, explain, deploy, monitor: models get worse as the world changes ("drift").
Baselines
Before any model, ask: what score does a dumb rule get? For regression: always predict the training average. For classification: always predict the most common class. A model that can't beat that isn't worth deploying, however clever it sounds.
Split, then score a baseline
Exercise
Beat the baseline
Using the same split, build a slightly smarter rule: predict the training average sales for each combination of branch and weekend. Set rmse_base (always the overall training mean) and rmse_rule (your rule) on the test set, both rounded to 1 decimal, and better to True if your rule wins.
Code that runs before yours
import pandas as pd
import numpy as np
daily = pd.read_csv("kc_daily.csv")
rng = np.random.default_rng(0)
is_test = rng.random(len(daily)) < 0.2
train, test = daily[~is_test], daily[is_test]Sorting drill
What kind of problem?
Sort each business question.
- How many croissants to bake tomorrow
- Is this card payment fraud?
- Group members into a few types for marketing
- Expected spend of a member next month
- Which of three offers will a member pick?
- Find branches that behave alike
0 of 6 sorted
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Exercises solved: 0 of 1
Written by Noviq Academy in its own words. Kettle & Crumb and all its data are made up for teaching; any resemblance to a real business is a coincidence. Python runs in your browser with Pyodide, so results can differ slightly from your own computer. Power BI, Tableau and other product names belong to their owners. Read-aloud uses your device's built-in voices.