Back to Study Material Machine Learning

Dataset, features, and labels

A dataset is the structured collection of examples a machine learning model learns from. Each example is called a sample or instance, and a collection of s...

Dataset, features, and labels

The Raw Materials of Every ML Model

A dataset is the structured collection of examples a machine learning model learns from. Each example is called a sample or instance, and a collection of samples forms the dataset. Understanding the anatomy of a dataset — features and labels — is foundational before any algorithm is chosen.

Features are the measurable properties of each sample. In a dataset of patients, features might include age, blood pressure, cholesterol level, and body mass index. Features are the inputs the model uses to make predictions. Choosing which features to include and how to represent them is one of the most important decisions a practitioner makes, because a model can only learn from information that is actually present in its inputs.

Labels are the answers or outcomes associated with each sample. In supervised learning the dataset includes labels: for the patient dataset the label might be whether the patient developed a particular condition. The model learns to map features to labels during training. In unsupervised learning there are no labels — the model looks for structure in the features alone.

Feature types matter. Numerical features like age can be used directly in most algorithms. Categorical features like blood type must usually be encoded — converted into numbers the algorithm can process. A common encoding is one-hot encoding, where each category becomes its own binary column.

A concrete example: predicting apartment rental prices. Features might be square footage, number of bedrooms, distance to the nearest subway stop, and neighborhood crime rate. The label is the monthly rent. The model learns which features correlate with higher or lower rent and by how much.

Exam tip: interviewers often ask the difference between features and labels — features are the inputs, labels are the outputs. They may also ask about feature leakage, where a feature inadvertently contains information from the future, making evaluation results unrealistically high.