Learning outcomes

After this lesson, you will be able to:

Core idea. In supervised learning, a model sees both the input and the known answer for each training example. The goal is to fit a model that predicts well for new cases—not merely to reproduce the training table.

1. What does “supervised” mean?

Supervised learning is a machine-learning setting in which every training example contains input features and a known target answer. Such examples are called labeled examples; their answers are called labels or targets.

Imagine a building operations log. For each day, we know the outdoor temperature, floor area, operating schedule and occupancy, as well as the actual energy consumption. The model receives the features and learns to predict consumption. Historical answers are examples from which it learns patterns—not hints that will be available for every future day.

Supervised learning: labeled examples to predictionInput features and known answers enter a learning algorithm. It fits a model that receives new features and returns a prediction.Labeled examplesX: featuresy: known answerspairs (X, y)Learning algorithmcompares predictionswith known answersFitted modelnew features X*prediction ŷSimplified view: model selection and evaluation use separate data splits.
Known answers help measure errors on training examples. After fitting, the model receives only the features of a new case.

The “teacher” does not have to be a person explaining every step. It is a metaphor for having a known answer against which a prediction can be compared. Answers may come from measurements, expert annotation, documents or event records.

2. Features, targets and labels

For one example, denote the input feature vector by X and its known answer by y. A supervised training dataset contains many pairs (X, y). Features describe the case; the target describes what we want to predict.

TaskInput features XTarget yAnswer type
Energy-use forecastTemperature, area, schedule, occupancyDaily energy consumptionNumber
Abnormal-operation detectionVibration, component temperature, pressureFault / normalClass
Service-request routingRequest text, equipment categoryRequest typeCategory

Label quality matters. If answers are wrong, inconsistent or reflect annotators’ subjective decisions, a model may learn to reproduce those errors. Rare events require particular care: check how labels were obtained and whether the examples represent the cases the model will encounter.

3. Two core task types: regression and classification

Regression

Regression predicts a numeric quantity: energy use, temperature, duration, price or load. The output lies on a numerical scale, and an error can often be described as a difference between the predicted and observed values.

Classification

Classification assigns a case to one of a set of classes: “normal” or “fault”, “type A” or “type B”, “spam” or “not spam”. A model may estimate class probabilities; a decision rule then turns them into a final label.

Do not confuse the terms. Regression and classification describe task types, not specific algorithms. A decision tree, for example, can be used for either task depending on the target.

4. How model training works

  1. Define the task. Specify the prediction unit, decision time and target variable.
  2. Prepare the data. Check features, labels, missing values, units and feature availability.
  3. Choose a model family. Examples include linear models, decision trees, ensembles and neural networks.
  4. Fit the model. The learning algorithm adjusts parameters to reduce error on training examples.
  5. Evaluate. Measure performance on data that was not used to fit the parameters.
  6. Predict. Pass the features of a new case to the fitted model.

During training, the model produces a prediction ŷ. A loss function measures how far that prediction is from the known answer y. An optimization algorithm uses the loss to update model parameters. The exact update rule depends on the model family and learning method.

X → model f(X; θ) → prediction ŷ → compare with y → update θ

Here θ denotes model parameters. Parameters are learned during fitting; hyperparameters are chosen before or around the fitting process. We will study them in later lessons.

5. Why split the data?

Evaluating a model on the same examples it used to fit its parameters can produce an overly optimistic result. A common protocol uses three sets:

The split must reflect the task. Random splitting may work for independent, similarly distributed observations. For forecasting, do not train on the future and evaluate on the past. If one entity appears repeatedly, use group-aware splitting so near-duplicate records do not cross train and test.

6. Example: forecasting a building’s energy use

Suppose we need to forecast tomorrow’s energy consumption. Features may include the weather forecast, calendar day, planned operating mode and occupancy information available before the forecast period. The target is the actual consumption during the following day.

Start with a simple baseline, such as the previous comparable day or the training-set average. Fit a model and compare it with the baseline on the same test period. If a complex model does not improve the result, its complexity is not yet justified.

No-code practice

Choose either daily energy forecasting or fault-event classification. Write down the observation unit, three features, the target and the time when the prediction must be made. For each feature, ask whether it will be available at that time.

7. Limitations and common mistakes

Supervised learning is useful when enough reliable labeled examples exist and the target is clearly defined. A large dataset alone does not guarantee quality: provenance, representativeness, independent evaluation and a realistic deployment scenario all matter.