Gradient LabStart the lesson

Lessons › Chapter 1: Foundations

Data, features and labels

Most ML starts with a table. Each row is one example (here, one house). Each column is one thing we measured about it.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

A spreadsheet of past loans

Leo opens a table of past loans: each row has income, age and loan amount, plus whether it was repaid. Every column is a clue, and the last one is the answer.

Concept

A dataset is a table

Most ML starts with a table. Each row is one example (here, one house). Each column is one thing we measured about it.

Concept

Features describe each example

The input columns are features. Here the bar heights show each house’s size, number of rooms and age. The model only ever sees these numbers.

Concept

The label is what we predict

The label (or target) is the answer we want: the price. During training the model sees features and labels together, and learns how one relates to the other.

Bigger size tends to go with a bigger price. That pattern is what gets learned.

Build

One row is one example

Pick one row. Its clues, written as a list, are its feature vector: [size, rooms, age]. Its answer is the label: the price. Training data is just lots of rows like this.

Build

Predictions fill in the blank

A new house arrives with features but no price. The trained model fills in the missing label. That is a prediction.

Real life

In real life: valuing a home

Property websites estimate what a home is worth. The features are things like size, rooms and age. The labels are the prices that past homes actually sold for. A new listing has features but no price yet: that’s the blank the model fills in.

Quick check: In a spam filter, which of these is the label?

The label is the answer you want to predict. The other two are features that help predict it.

Pseudocode

table = load "houses"
# each row = one house
features = columns size, rooms, age    # the clues
label = column price                   # the answer
# 5 rows, 3 feature columns

new_house = [size 120, rooms 3, age 10]    # no price yet
model.guess(new_house)                     # fills in the price

Key terms

feature
One clue about an example, like a house’s size. A column in the table.
label
The right answer for an example, the thing we want the model to guess.
feature vector
All the clues for one example, written as a list of numbers.
prediction
The model’s guess for an example it is shown.

Build it: Your first ML model: an iris flower classifier (20 min, runs in your browser)

See the project

Build it: House price predictor (30 min, runs in your browser)

See the project