Understand machine learning problems
Frame a problem as classification, regression or clustering, and name its examples, features and target.
- Distinguish supervised and unsupervised learning
- Tell classification from regression
- Decide when machine learning is the right tool at all
Ordinary programs follow rules a person wrote. Machine learning (ML) programs learn their rules from examples. Show a model thousands of houses with their prices, and it learns a function from house features to price; then it can price a house it has never seen.
- Supervised learning - every training example has a known answer, the target (or label). Predicting a category is classification (spam or not, which disease); predicting a number is regression (price, delivery time).
- Unsupervised learning - no targets. The model finds structure: clustering groups similar examples; dimensionality reduction compresses many features into a few.
Each example is described by features - the inputs, like rooms and area. Formally, a supervised model learns a function that maps features to a prediction close to the true target .
Try it
Up to 15 XPWhat kind of problem is it?
Sort each task.
“Flag card transactions as fraudulent or legitimate”
“Estimate how many minutes a delivery will take”
“Group customers by shopping behavior, with no predefined segments”
“Compute sales tax from a fixed tax table”
“Predict next month’s electricity demand in megawatts”
“Recognize which of 10 digits a handwritten image shows”
1houses = [
2 {"rooms": 3, "area_m2": 82, "price": 275000},
3 {"rooms": 2, "area_m2": 55, "price": 190000},
4]
5features = [[house["rooms"], house["area_m2"]] for house in houses]
6targets = [house["price"] for house in houses]
7print(features, targets)[[3, 82], [2, 55]] [275000, 190000]
Key takeaways
Supervised learning learns from examples with known targets.
Classification predicts categories; regression predicts numbers; clustering finds groups without labels.
Define the real task, the target and what a useful result is before picking an algorithm.
Lesson quiz
6 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write Python
Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.
Split features from the target
Read a CSV where the last column is the target. Print features: NAMES (comma-separated), target: NAME, examples: N, and task: classification if every target value is non-numeric, otherwise task: regression.
- House prices
- Spam
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Beat the baseline
Line 1 lists training labels; line 2 lists test labels (space-separated). A baseline that always predicts the most common training label (alphabetically first on ties) is the first thing any model must beat. Print baseline: LABEL and baseline accuracy: P% on the test labels (whole percent).
- Imbalanced classes
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…