Features and Labels · Machine Learning & AI
Ch 2 · Data — Features, Labels & Splitting — card 1 of 2.
Every row of training data has two parts: the inputs a model learns from, called features, and the answer you want it to predict, called the label. Telling them apart is the first step in any supervised project. In the example, each row pairs hours studied with a pass (1) or fail (0), and the code separates them into a features list and a labels list.
- 🔢 A feature is an input the model learns from (hours studied, email length).
- 🎯 The label is the answer we want to predict (pass/fail, spam/not-spam).
# rows of (feature, label)
dataset = [(1, 0), (2, 0), (4, 1), (5, 1)]
features = [row[0] for row in dataset]
labels = [row[1] for row in dataset]
print("features:", features)
print("labels: ", labels)