Supervised Learning Stay organized with collections Save and categorize content based on your preferences.
Page Summary
Supervised learning uses labeled data to train models that predict outcomes for new, unseen data.
The training process involves feeding the model labeled examples, allowing it to learn the relationship between features and labels.
Models are evaluated by comparing their predictions on unseen data to the actual values, helping to refine their accuracy.
Once trained and evaluated, models can be used for inference, making predictions on new, unlabeled data in real-world applications.
The quality of the dataset, including its size and diversity, significantly impacts the model's performance and ability to generalize.
Supervised learning's tasks are well-defined and can be applied to a multitudeof scenarios—like identifying spam or predicting precipitation.
Foundational supervised learning concepts
Supervised machine learning is based on the following core concepts:
- Data
- Model
- Training
- Evaluating
- Inference
Data
Data is the driving force of ML. Data comes in the form of words and numbersstored in tables, or as the values of pixels and waveforms captured in imagesand audio files. We store related data in datasets. For example, we might have adataset of the following:
- Images of cats
- Housing prices
- Weather information
Datasets are made up of individualexamples that containfeatures and alabel. You could think of an example asanalogous to a single row in a spreadsheet. Features are the values that asupervised model uses to predict the label. The label is the "answer," or thevalue we want the model to predict. In a weather model that predicts rainfall,the features could belatitude,longitude,temperature,humidity,cloud coverage,wind direction, andatmospheric pressure. Thelabel would berainfall amount.
Examples that contain both features and a label are calledlabeled examples.
Two labeled examples

In contrast, unlabeled examples contain features, but no label. After you createa model, the model predicts the label from the features.
Two unlabeled examples

Dataset characteristics
A dataset is characterized by its size and diversity. Size indicates the numberof examples. Diversity indicates the range those examples cover. Good datasetsare both large and highly diverse.
Datasets can be large and diverse, or large butnot diverse, or small but highly diverse. In other words, alarge dataset doesn't guarantee sufficient diversity, and a dataset that ishighly diverse doesn't guarantee sufficient examples.
For instance, a dataset might contain 100 years worth of data, but only for themonth of July. Using this dataset to predict rainfall in January would producepoor predictions. Conversely, a dataset might cover only a few years but containevery month. This dataset might produce poor predictions because it doesn'tcontain enough years to account for variability.
Check Your Understanding
A dataset can also be characterized by the number of its features. For example,some weather datasets might contain hundreds of features, ranging from satelliteimagery to cloud coverage values. Other datasets might contain only three orfour features, like humidity, atmospheric pressure, and temperature. Datasetswith more features can help a model discover additional patterns and make betterpredictions. However, datasets with more features don'talways produce modelsthat make better predictions because some features might have no causalrelationship to the label.
Model
In supervised learning, a model is the complex collection of numbers that definethe mathematical relationship from specific input feature patterns to specificoutput label values. The model discovers these patterns through training.
Training
Before a supervised model can make predictions, it must be trained. To train amodel, we give the model a dataset with labeled examples. The model's goal is towork out the best solution for predicting the labels from the features. Themodel finds the best solution by comparing its predicted value to the label'sactual value. Based on the difference between the predicted and actualvalues—defined as theloss—themodel gradually updates its solution. In other words, the model learns themathematical relationship between the features and the label so that it canmake the best predictions on unseen data.
For example, if the model predicted1.15 inches of rain, but the actual valuewas.75 inches, the model modifies its solution so its prediction is closer to.75 inches. After the model has looked at each example in the dataset—insome cases, multiple times—it arrives at a solution that makes the bestpredictions, on average, for each of the examples.
The following demonstrates training a model:
The model takes in a single labeled example and provides a prediction.

Figure 1. An ML model making a prediction from a labeled example.
The model compares its predicted value with the actual value and updates its solution.

Figure 2. An ML model updating its predicted value.
The model repeats this process for each labeled example in the dataset.

Figure 3. An ML model updating its predictions for each labeled examplein the training dataset.
In this way, the model gradually learns the correct relationship between thefeatures and the label. This gradual understanding is also why large and diversedatasets produce a better model. The model has seen more data with a wider rangeof values and has refined its understanding of the relationship between thefeatures and the label.
During training, ML practitioners can make subtle adjustments to theconfigurations and features the model uses to make predictions. For example,certain features have more predictive power than others. Therefore, MLpractitioners can select which features the model uses during training. Forexample, suppose a weather dataset containstime_of_day as a feature. In thiscase, an ML practitioner can add or removetime_of_day during training to seewhether the model makes better predictions with or without it.
Evaluating
We evaluate a trained model to determine how well it learned. When we evaluate a model,we use a labeled dataset, but we only give the model the dataset's features. Wethen compare the model's predictions to the label's true values.

Figure 4. Evaluating an ML model by comparing its predictions to the actualvalues.
Depending on the model's predictions, we might do more training and evaluatingbefore deploying the model in a real-world application.
Check Your Understanding
Inference
Once we're satisfied with the results from evaluating the model, we can use themodel to make predictions, calledinferences, onunlabeled examples. In the weather app example, we would give the model thecurrent weather conditions—like temperature, atmospheric pressure, andrelative humidity—and it would predict the amount of rainfall.
Key Terms:Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-25 UTC.