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

KindYou haveThe model learns to…Café example
Supervised: regressionInputs and a numeric answerPredict a numberTomorrow's sales from weather and weekday
Supervised: classificationInputs and a category answerPredict a class (and a probability)Will this member churn: yes or no?
Unsupervised: clusteringInputs only, no answerFind groupsSegments of members with similar habits
Unsupervised: anomaly detectionInputs onlyFlag unusual rowsA 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

  1. Frame the question: what decision will the prediction change? What counts as good enough?
  2. Get and clean data (Modules 3–5).
  3. Engineer features (Module 10).
  4. Split: training set to learn from, test set locked away to judge at the end.
  5. Train and compare models against a baseline.
  6. 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

Question 1

1.The test set should be used…

Question 2

2.A classifier is 74% accurate; 74% of members don't churn. It is…

Question 3

3.Finding customer segments with no labels is…

Quiz score: 0 of 3

Exercises solved: 0 of 1

Tip: answer every quiz question correctly first.

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.