Learning outcomes
After this lesson, you will be able to:
- Explain supervised learning and why training examples need known answers.
- Distinguish input features X, a target variable y and a class label.
- Tell regression tasks from classification tasks.
- Describe the path from a training dataset to a prediction from a fitted model.
- Explain the roles of training, validation and test sets.
- Identify limitations related to labels, data quality and performance on new cases.
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.
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.
| Task | Input features X | Target y | Answer type |
|---|---|---|---|
| Energy-use forecast | Temperature, area, schedule, occupancy | Daily energy consumption | Number |
| Abnormal-operation detection | Vibration, component temperature, pressure | Fault / normal | Class |
| Service-request routing | Request text, equipment category | Request type | Category |
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.
4. How model training works
- Define the task. Specify the prediction unit, decision time and target variable.
- Prepare the data. Check features, labels, missing values, units and feature availability.
- Choose a model family. Examples include linear models, decision trees, ensembles and neural networks.
- Fit the model. The learning algorithm adjusts parameters to reduce error on training examples.
- Evaluate. Measure performance on data that was not used to fit the parameters.
- 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.
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:
- Train — used to fit model parameters.
- Validation — used to compare model options and tune hyperparameters.
- Test — reserved for a final independent evaluation after the approach has been selected.
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
- Poor labels. The model receives incorrect or contradictory answers.
- Sampling bias. Training examples do not represent real deployment conditions.
- Data leakage. Features reveal information unavailable at prediction time, or test data influence fitting.
- Overfitting. The model adapts too closely to training examples and performs worse on new cases.
- Wrong metric. The chosen score does not reflect the real cost of 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.