2 Datasets and Features
Learn how machine-learning datasets are structured, what makes their data suitable for a prediction task, and how to prepare them without compromising evaluation.
structure and prediction targets
A is a collection of examples used to develop or apply a machine-learning model. It may be stored as a table, with each row representing an example and each column recording an attribute, or it may contain other forms of data, including text, images, or audio.
A , also called an example, is one case the model learns from or makes a prediction about. A is an input attribute that may help the model make a prediction. A is the known outcome the model is meant to predict; in supervised learning, a labeled contains both features and a .
For a home sale-price prediction task, each home is a . Size, bedroom count, and neighborhood are features, while sale price is the . For example, one home might have a size of 90 square meters, 2 bedrooms, and a North neighborhood designation, with a sale price of ; another might have a size of 140 square meters, 3 bedrooms, and a South neighborhood designation, with a sale price of . The should represent the outcome the model is actually intended to predict. If that exact outcome is unavailable, a may be used, but it is only an approximation and may not match the real goal.
Assessing
A model’s usefulness depends partly on whether its is accurate and appropriate for the task. Common data-quality problems include missing values, duplicate samples, incorrect values, mislabeled examples, and samples that do not represent the cases the model will encounter.
Representativeness matters: home records collected only from expensive neighborhoods may poorly represent homes elsewhere. Data should also be checked for inconsistent formats, units, and category names.
is task-dependent. Data is useful when it supports the intended prediction and reflects the real-world setting where that prediction will be used. Features should be available at prediction time; including information that would become known only afterward can make results misleading.
Preparing data for modeling
Clarify the prediction goal. Define what one represents and what the model should predict.
Inspect and validate the data. Check the meanings of rows and columns, data types, units, plausible ranges, missing values, duplicates, and consistency. Automated checks can flag values that violate known rules.
Handle missing or erroneous values. Correct errors when possible. Otherwise, decide whether to remove affected samples or fill in missing values using a suitable method. Record important choices rather than treating them as invisible fixes.
Convert features into usable representations. Numerical values may need scaling, and categories such as neighborhood names may need numerical encoding. Apply consistent transformations to future data as well.
Keep evaluation data separate during preparation. First divide the data into training and test sets. Learn preprocessing choices—such as averages used to fill missing values or scaling—from the , then apply those same choices to the . Using test data to learn preprocessing is and can make evaluation overly optimistic.