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.

# 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)