Loading
0x00Lesson 1 of 11

Understand machine learning problems

Frame a problem as classification, regression or clustering, and name its examples, features and target.

18 min 6-question quiz 2 code exercises
By the end of this lesson you can
  • 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 y^=f(x)\hat{y} = f(x) that maps features xx to a prediction y^\hat{y} close to the true target yy.

Try it

Up to 15 XP

What kind of problem is it?

Sort each task.

0 of 6 sortedScore 0/0
  • “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”

examples.py
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)
Output
[[3, 82], [2, 55]] [275000, 190000]

Key takeaways

  • Supervised learning learns y^=f(x)\hat{y} = f(x) 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.

Exercise 1

Split features from the target

+25 XP

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
main.py
Loading editor…

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.

Exercise 2

Beat the baseline

+25 XP

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
main.py
Loading editor…

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…