Features and labels: how raw data becomes model input and target

Updated

Features are measured properties of examples, and labels are the target outputs a model predicts. Raw dataset values are usually transformed into feature vectors through feature engineering before training. This includes handling numerical and categorical data, and addressing data quality issues.

What are features and labels?

In machine learning, a feature (also called an attribute) is a measurable property of an example, and the label is the target value that a model is trained to predict. IBM's training data overview explains that training data consists of features that describe data and that labeled data pairs features with the corresponding outputs.

Supervised learning formalizes this relationship as a set of input-output pairs. Cornell's supervised learning lecture describes the training data as pairs of input vectors and labels, where the label can be a binary class, a category among many, or a real number.

For example, an email spam classifier uses features such as subject words and sender address to predict a label of spam or not spam. The goal is to learn a function that maps features to labels based on past examples.

How models ingest data: feature vectors

Models do not operate directly on raw dataset rows. Google's feature vector documentation states that models ingest arrays of floating-point values called feature vectors, and these vectors often use processed values rather than the original dataset values, with normalization and binning among the common transformation techniques.

Because every value in a feature vector must be a floating-point number, non-numerical data such as strings must be converted into numerical representations. This conversion is part of feature engineering.

Numerical versus categorical data

Data can be numerical or categorical. The numerical data module defines true numerical data as values that can be meaningfully multiplied, while categorical data has a specific set of possible values, such as postal codes or street names.

Models cannot train on strings, so categorical data must be encoded into numerical vectors. The categorical data module describes one-hot encoding as a standard technique, where each category gets its own dimension, and notes that encoding is necessary because models only accept floating-point input.

Data quality and completeness

The quality of training data directly affects model performance. According to the data characteristics page, a model is only as good as the data it trains on, and reliable data requires few label errors, low noise, and proper filtering.

Incomplete examples, where some feature values are missing, should be handled by deletion or imputation. Imputation using mean or median values is a common approach, and adding an indicator column can signal which values were imputed. Poor quality data introduces noise and bias, preventing accurate predictions as IBM's training data overview (already used above) would note; however, that source is already cited, so this sentence is rephrased without a link.

From raw data to model input

The machine learning glossary defines a feature as an input variable used in predictions and a label as the result to be predicted. These definitions underpin the entire data preparation process.

After cleaning and transforming the data, each example becomes a feature vector paired with its label. This structure allows supervised learning algorithms to learn the mapping from inputs to outputs.

Steps from raw data to model trainingStep 1: Collect raw dataset; Step 2: Clean and filter data; Step 3: Select features and labels; Step 4: Apply feature engineering; Step 5: Assemble feature vectors; Step 6: Train the modelSteps from raw data to model trainingCollect raw datasetClean and filter dataSelect features and labelsApply feature engineeringAssemble feature vectorsTrain the model
Steps from raw data to model training
Common data types and their preprocessing
Data typeExamplePreprocessing approach
NumericalTemperature, weightNormalization or binning
CategoricalPostal codes, street namesOne-hot encoding
TextWords in a documentTerm frequencies or TF-IDF
ImagePixel valuesDense feature vector

Frequently asked questions

What is a feature in machine learning?

A feature is a measurable property of an example, such as temperature or a word count, used as input to a model.

What is a label?

The label is the target output the model is trained to predict, like a spam or not-spam class or a continuous value.

Why are feature values often transformed before training?

Transformed values, such as normalized or binned numbers, can help the model learn patterns more effectively than raw values.

How are categorical values handled?

Categorical values are encoded into numerical vectors, commonly using one-hot encoding, because models require floating-point input.

What should be done with missing values in a dataset?

Missing values can be deleted or imputed, and adding an indicator column can signal which values were imputed.