learn-classification-regression-with-phoebe / Session 1 of 10
Learn Classification & Regression with Phoebe · Session 1 of 10

Welcome to the supervised zoo

Intro-ML taught you the workflow: split the data, train on train, judge on test, tune with cross-validation - using just one classifier and one tree. This course opens the cage doors. Seven classic algorithms - linear regression, logistic regression, gradient descent, k-nearest neighbors, naive Bayes, decision trees, and support vector machines - each get a session of real depth: how they think, what their knobs do, when they win, and when they quietly lose. Same Lumen Skincare data, same seed 42, so every number reconciles with the courses you have already taken. Today you meet the whole zoo, learn the one picture that explains them all - the decision boundary - and set up the leaderboard the next nine sessions will fill in.

🟢 Start here Builders · DA / DE / DS Python · scikit-learn 45 min
0-3 · Setup 3-18 · The zoo map 18-40 · Boundaries & baselines 40-45 · Wrap
Part 0

One question, seven ways of answering it

Every algorithm in this course answers the same two Lumen questions - will this session convert, and how big will the order be - but each answers in its own voice. A linear model draws a straight line. A tree asks yes/no questions. kNN just looks at the neighbors. Naive Bayes multiplies probabilities. An SVM hunts for the widest gap. None of them is "the best one"; each is a different bet about what shape the truth has. Learning the zoo means learning which bet fits which data - that judgement is what separates someone who calls .fit() from someone who models.

Live - built in session Self-study - run after ★ The one big idea The case: Lumen Skincare
★ What you walk out with today The map of the seven algorithms and the two families they belong to (model-based vs instance-based), the one picture that compares them all - the decision boundary - explored live in your browser, and a rebuilt Lumen dataset plus a three-model baseline script whose leaderboard (logistic ~0.69, tree ~0.66, kNN ~0.64 ROC-AUC) you will fully understand, beat, and explain by session 10.
Part 1 · the map

Seven algorithms, two families 8 min live

The zoo looks big until you see the family resemblance. Model-based algorithms compress the training data into a small set of learned numbers - weights, split rules, class statistics - then throw the data away. Instance-based algorithms keep the data and answer by looking things up. That one distinction predicts most of each algorithm's personality: training speed, prediction speed, memory, and how the boundary looks.

The supervised zoo - who lives where MODEL-BASED learn numbers, discard the data Linear reg. a straight line through $ values → session 2 Logistic reg. a line pushed through sigmoid → sessions 3-4 Naive Bayes multiply class probabilities → session 6 Decision tree stacked yes/no questions → session 7 INSTANCE-BASED k-nearest neighbors keep all the data, ask the neighbors → session 5 Support vector machines - a foot in both camps Learns a boundary like a model-based method, but the boundary is defined by a few remembered training points (the support vectors). Kernels let the line bend. → session 8 Sessions 9-10: no new animals How to CHOOSE from the zoo (9), then the full bake-off on both Lumen tasks (10). One distinction carries the map: compress the data into numbers, or keep the data and look it up.
🔍 Click to zoom - the seven algorithms and their two families
LiveWhat intro-ml already gave you (and what we will not repeat)3 min▶

This course assumes the intro-ml builder track. In one breath: you split data into train and test before looking at it, you fit models (and scalers!) on train only, you never trust raw accuracy on imbalanced data (Lumen converts ~3%, so "always no" is ~97% accurate and useless), you read classifiers with ROC-AUC / precision / recall and regressors with RMSE / MAE / R², and you tune with cross-validation, never on the test set.

We will use all of that constantly and re-teach none of it. If any sentence above felt foggy, take learn-intro-ml-with-phoebe ↗ first - this course starts where its b10 capstone ended.

The contract: intro-ml = the workflow. This course = the algorithms. Feature engineering, ensembles (XGBoost and friends), and deep learning each get their own course later - we name them when we brush against them.
LiveParametric vs non-parametric - the vocabulary that unlocks the docs4 min▶

Parametric models have a fixed number of learned parameters no matter how much data you feed them. Linear regression on 7 features learns 8 numbers whether you train on 400 rows or 40 million. That makes them fast, small, and stable - and caps how bendy they can get.

Non-parametric models grow with the data. kNN's "model" is the whole training set; a tree can keep splitting as long as rows remain. They can fit almost any shape - which is power and danger in one feature: the bendier the family, the easier it memorizes noise.

scikit-learn's user guide calls kNN "non-generalizing" for exactly this reason: it does not compress the data into a generalization, it remembers. You will feel the consequence in the live tool below - and measure it properly in session 5.

Real worldA fraud team asked why their kNN scorer needed 40 GB of RAM in production while the logistic model next to it needed kilobytes. Answer: kNN ships the training data as the model. Parametric vs non-parametric is not textbook trivia - it is your memory bill.
LiveThe two Lumen tasks, one last time3 min▶

Same brand, same generator, seed 42 - the dataset you built in intro-ml b1 and the numbers that reconcile with the statistics and experimentation courses:

TaskTargetShapeThe floor to beat
Will this session convert?converted (0/1, ~3% yes)Classification"always no" - ~97% accuracy, catches nobody
How big will the order be?order_value ($, mean ~$73)Regression"predict the mean" - RMSE ~$40 on buyers

Every algorithm in the zoo will face both tasks (where it can). By session 10 you will have a leaderboard for each - and the honest surprise of this course is which models top it.

Part 2 · the one picture

The decision boundary - where a model changes its mind 10 min live

Take any classifier, feed it every point on a 2D map, and paint each point by the predicted class. The seam between the colors is the decision boundary - the set of places where the model flips from "no" to "yes". Every classifier in the zoo draws this seam in its own signature style: logistic regression draws one straight line, trees carve axis-parallel rectangles, kNN traces the local crowd, RBF kernels wrap curves around clusters. Learn to read this picture and you can identify an algorithm from its boundary like a naturalist reading footprints.

Logistic / linear SVM One straight seam. Calm, stable, biased. Decision tree Axis-parallel cuts. Rectangles only. k-nearest neighbors Follows the crowd. Wobbly where data is. RBF kernel SVM Smooth curved blobs around clusters. Four signatures, one legend: magenta = predicted convert, cyan = predicted no. You will meet all four live below.
🔍 Click to zoom - four boundary signatures you will learn to recognize
LivePlay: the boundary explorer6 min▶

These are real models fit live in your browser - real gradient descent, real CART splits, real neighbor votes. Two datasets: Lumen real is 300 actual generator points (150 converters, 150 non-converters, spend x pages standardized), and Lab: two moons is a stylized shape for geometry intuition - clearly not Lumen data. Try this script:

  • Start on Lab + kNN. Drag k down to 1: train accuracy hits ~100% while test accuracy sinks. That gap IS overfitting - you will see it on every algorithm all course.
  • Switch to tree and crank depth: watch it carve one rectangle per stray point.
  • Switch to Lumen real: every algorithm gets humbler. Two features of real checkout data hold a weak, honest signal (~60% accuracy on a balanced sample) - real data whispers, it does not shout.
Keep this tool in mind: sessions 3, 5, 7 and 8 each come back to it with their own algorithm and knob. By session 9 you will predict the boundary shape before you select it.
Self-studyWhy only two features in the picture?4 min▶

Real Lumen models use all seven features; boundaries live in 7-dimensional space and cannot be drawn. Two features are a teaching window, not a recommendation - and the window has a catch: with fewer features, the models above score lower than the ~0.69 ROC-AUC you will get with the full feature set in session 3.

The shapes, however, generalize perfectly: a logistic model in 7D draws a flat 6-dimensional plane exactly as it draws a line in 2D; a tree still cuts one feature at a time; kNN still votes among neighbors. Learn the geometry in 2D, trust it in 7D.

Build-along

Rebuild Lumen, then meet your baselines ★ 18 min · everyone builds

Two jobs: regenerate the exact Lumen dataset (seed 42 - if you still have lumen_sessions.parquet from intro-ml, this run will produce the identical file), then fit one representative from three families with identical code and stand up the leaderboard this course exists to explain.

Recreate the dataset. Run the generator exactly as intro-ml b1 shipped it - same seed, same coefficients. Sanity-check the fingerprint: 40,000 rows, ~3% conversion, AOV mean ~$73.

Build the shared preprocessing. One ColumnTransformer: one-hot the four categoricals, scale the three numerics. Fit on train only - the b2 discipline, forever.

Fit three animals with one loop. Same Pipeline, three estimators swapped in - the estimator API is why this is three lines, not three scripts.

Read the leaderboard. ROC-AUC on the held-out test set. Do not explain the ranking yet - explaining it is the whole course.

baselines.py - the leaderboard we will spend nine sessions understandingimport pandas as pd from sklearn.model_selection import train_test_split from sklearn.compose import ColumnTransformer from sklearn.preprocessing import OneHotEncoder, StandardScaler from sklearn.pipeline import Pipeline from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import roc_auc_score df = pd.read_parquet("lumen_sessions.parquet") cat = ["channel", "device", "new_vs_returning", "product_category"] num = ["pages_viewed", "session_hour", "prior_30d_spend"] X, y = df[cat + num], df["converted"] X_tr, X_te, y_tr, y_te = train_test_split( X, y, test_size=0.25, random_state=42, stratify=y) prep = ColumnTransformer([ ("cat", OneHotEncoder(handle_unknown="ignore"), cat), ("num", StandardScaler(), num)]) zoo = { "logistic": LogisticRegression(max_iter=2000), "tree d=5": DecisionTreeClassifier(max_depth=5, random_state=42), "kNN k=101": KNeighborsClassifier(n_neighbors=101)} for name, model in zoo.items(): pipe = Pipeline([("prep", prep), ("model", model)]).fit(X_tr, y_tr) proba = pipe.predict_proba(X_te)[:, 1] print(f"{name:10s} ROC-AUC {roc_auc_score(y_te, proba):.2f}") # logistic ROC-AUC 0.69 # tree d=5 ROC-AUC 0.66 # kNN k=101 ROC-AUC 0.64
If your numbers differ in the 2nd decimal: fine - tiny library-version jitter is normal. If they differ in the 1st decimal, check the seed (42 in the generator AND the split) and that the scaler sits inside the pipeline, not before the split.
Real worldNotice what just happened operationally: swapping algorithms was a one-line change inside a dict. Teams that structure experiments this way test seven models in the time others test one - the estimator API is a productivity feature disguised as a design choice.
Homework

Before session 2 ◐ 25 min

Check yourself

Three questions before you go 🎯 ◐ 90 seconds

1 · What is the decision boundary of a classifier?

Paint every point in feature space by predicted class; the seam where the color changes is the boundary. Its shape is the algorithm's signature: line, rectangles, local wobble, or smooth curves.

2 · kNN is called "instance-based" (or "non-generalizing") because...

kNN's model IS the training data. That buys flexibility (any boundary shape) and costs memory and prediction speed - the family trade-off in one algorithm. It handles regression fine (session 5).

3 · In the explorer, kNN with k=1 shows train accuracy ~100% and much lower test accuracy. What is that gap called and why does it appear?

At k=1 each training point predicts itself perfectly, so the boundary wraps around every noisy point. Perfect train score, poor test score - the overfitting tell you will re-meet on trees (depth), polynomials (degree), and RBF (gamma).

Source material

What this session covers

Session 1 covers the orientation layer of the anchor sources - the supervised-learning map and the vocabulary - so each later session can go deep on one animal. Certificates, videos, and graded labs stay with the official providers.

✓The supervised zoo map: model-based vs instance-based, parametric vs non-parametricPart 1
✓Decision boundaries as the universal comparison picturePart 2 + live tool
✓scikit-learn supervised-learning guide - module map (1.1, 1.4, 1.6, 1.9, 1.10)the course's spine
◐Andrew Ng ML Specialization C1 W1 - supervised learning framingrecap only; intro-ml owns it
◐The workflow itself (splits, CV, metrics)learn-intro-ml-with-phoebe - assumed, not re-taught

Session 1 cheat sheet · pin this

The zooLinear reg (s2), logistic (s3) + gradient descent (s4), kNN (s5), naive Bayes (s6), trees (s7), SVM (s8), then choosing (s9) and the bake-off (s10).
Two familiesModel-based: compress data into learned numbers (linear, logistic, NB, tree). Instance-based: keep the data, look up neighbors (kNN). SVM straddles both.
Parametric or notParametric = fixed number of parameters regardless of data size (fast, small, stiff). Non-parametric = grows with data (flexible, hungry, memorizes if unchecked).
Decision boundaryWhere the predicted class flips. Logistic: straight line. Tree: axis-parallel rectangles. kNN: local wobble. RBF: smooth curves. Read the footprint, name the animal.
The overfitting tellTrain accuracy high, test accuracy low - the gap. Same tell on every knob: k, depth, degree, gamma.
The starting leaderboardFull features, ROC-AUC: logistic ~0.69, tree(d5) ~0.66, kNN(k=101, scaled) ~0.64. Beating and explaining this is the course.