Supervised learning

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Statistical learning.

In statistical learning, supervised learning is the fitting of a rule that predicts an observed outcome from features, using cases in which both were recorded. When each recorded case carries both the measurements and the outcome, the outcome can be used to score a proposed rule. Supervised learning is that use: fit a rule that predicts the outcome from the measurements, on cases where the outcome was observed.[1][2]

Supervised learning

Supervised learning
Fact Value
Topic Statistical learning
Listed on Statistical learning
Worked example 1

Motivating example

Three training cases sit on a line: a feature 00 with label 00, a feature 11 with label 00, and a feature 44 with label 11. A one-nearest-neighbour rule, asked about a new feature 33, finds the training feature 44 as the nearest and returns the label 11. Asked about a new feature 22, it finds the training feature 11 and returns the label 00. The labels on the three training cases are what make those two answers possible. Without the labels, the distances would still be defined and the prediction would not.[2][1]

Definition

Supervised learning, or learning with a teacher, starts from inputs XX and one or more outputs YY, observed together on a training sample (xi,yi)(x_i,y_i). The fitted rule predicts YY from XX on a new case. If (X,Y)(X,Y) has a joint distribution, the target is a property of the conditional distribution of YY given XX, often the value μ(x)\mu(x) that minimises the expected loss at that xx. The marginal distribution of XX is not the object. A squared loss L(y,y^)=(y−y^)2L(y,\hat y)=(y-\hat y)^2 is the usual example of the teacher’s score.[1]

In the usual division, each observation i=1,…,ni=1,\ldots,n has predictors xix_i and a response yiy_i. The fit aims at prediction of a future response, or at inference about how the response is associated with the predictors. Linear regression, binary logistic regression, generalised additive models, boosting, and support vector machines are supervised methods. So is linear discriminant analysis.[2]

The inputs are also called predictors or features. The outputs are responses. A quantitative output is a regression problem. A qualitative output is a classification. Logistic regression is typically used with a binary response, so it is a classification method, and because it estimates class probabilities it is also a regression for that probability.[1][2]

Under squared error the rule with the smallest expected prediction error is the conditional mean. Under absolute error it is the conditional median. One-nearest neighbour tries to estimate a local conditional mean, or a local class, by using the closest training cases.[1]

Properties

For the three training pairs (0,0)(0,0), (1,0)(1,0) and (4,1)(4,1), the nearest training feature to a query xx determines the one-nearest-neighbour label. The distances from 33 are ∣3−0∣=3|3-0|=3, ∣3−1∣=2|3-1|=2 and ∣3−4∣=1|3-4|=1, so the label is 11. The distances from 22 are 22, 11 and 22, so the nearest training feature is 11 and the label is 00. The distances from 2/52/5 are 2/52/5, 3/53/5 and 18/518/5, so the label is 00.

On the training points themselves, each point is at distance 00 from itself and at a positive distance from the others. The one-nearest-neighbour label of each training point is the label that was recorded there, and the training error is 00. That identity uses the labels twice: once to store them, and once to score them.[1]

A partial version of the same structure is semi-supervised learning: responses are observed for mm of the nn cases and missing for the rest, and a method may use both parts. That extension is named as a separate case, outside the basic split into fully labelled and fully unlabelled samples.[2]

The conditional-risk target assumes future cases come from the same joint distribution as the training pairs, and that the loss used in fitting is the loss of the decision. A sample of labels that were assigned by a different process supervises a different problem. One-nearest neighbour stores the whole training sample and treats the closest label as the truth. In a region where the two classes overlap, that rule has a larger error than a rule based on the conditional probabilities. The training error of 00 does not measure that overlap.[1]

Statistical use

Use a supervised method when the response on future cases is the decision and a sample of past responses exists. A binary clinical outcome is a setting for binary logistic regression or linear discriminant analysis. A local rule, with no global formula, is a setting for nearest neighbours or a decision tree. The training cases estimate the rule. A later case, or a cross-validation fold, estimates the loss of the rule.[2][1]

The loss should match the decision. Squared error fits a conditional mean. A misclassification count fits a class label. Estimating the conditional probabilities and then choosing the most probable class is the Bayes classifier when those probabilities are known, and it is the target of many fitted classifiers when they are not.[1]

Worked example

Training pairs (0,0)(0,0), (1,0)(1,0) and (4,1)(4,1) define a one-nearest-neighbour rule. At a new feature 33 the distances to the training features are 33, 22 and 11. The nearest training feature is 44, so the predicted label is 11. At a new feature 22 the distances are 22, 11 and 22. The nearest training feature is 11, so the predicted label is 00. At each training feature the nearest neighbour is the point itself, so all three training labels are reproduced and the training error is 00.

Your turn. What label does this rule return at the feature 2/52/5?

The distances from 2/52/5 to 00, 11 and 44 are 2/52/5, 3/53/5 and 18/518/5. The nearest training feature is 00, so the label is 00.

Common misconceptions

A supervised analysis is not any analysis that uses a computer, and it is not a clustering of the features. Clustering does not have a response to predict. If the labels in the example are thrown away, the distances remain and the predicted label does not.[2][1]

Logistic regression is supervised classification. The response is qualitative. The fitted probability is a means to a class, and also a regression for that probability. The name “regression” in the method does not turn the problem into an unlabelled one.[2]

A training error of 00, as in the one-nearest-neighbour calculation above, is not an estimate of the error on a feature that was not in the training set. The query at 33 is a different question from the query at 44.[1]

Connections

Classification is supervised learning with a qualitative response. Simple linear regression is supervised learning with a quantitative response. Unsupervised learning drops the response. Inside classification, linear discriminant analysis, binary logistic regression, nearest neighbours and decision trees are different supervised rules for the same kind of YY. The training set is the collection of pairs the rule may use.[2][1]

Check yourself

Try these questions before opening an answer.

Training error of zero

One-nearest neighbour reproduces every training label, so the training error is zero. Why is that not an estimate of the error at a new feature?

Each training point is its own nearest neighbour, so the score uses the labels twice. A new feature is a different query, and the training error does not measure overlap between the classes.

Logistic regression

Why is logistic regression supervised learning even though the method has regression in its name?

The training cases carry a qualitative response. The fitted probability is a means to a class, so the response supervises the fit.

Labels removed

If the labels on a supervised training sample are thrown away, what remains and what is lost?

The distances among the features remain. The predicted label does not, because there is no response left to return.

History

The organised division into learning with a teacher and learning without one is the framework of the modern statistical-learning texts. Most of the early development is supervised: a response is present, a loss scores the rule, and squared error picks out the conditional mean. Linear regression, logistic regression, generalised additive models, boosting, and support vector machines are placed in that supervised class. One-nearest neighbour is the simple local rule against which more structured fits are compared. The texts then gather the unsupervised methods, which have no response, in a later chapter.[2][1]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h i j k l m a. (pp. 485–486, §14.1) b. (pp. 9–11, the nearest-neighbour rule in the overview; pp. 485–486, §14.1) c. (pp. 485–486, §14.1, (14.1)) d. (pp. 9–10) e. (pp. 18–20, §2.4) f. (pp. 9–11) g. (pp. 18–20, §2.4; pp. 485–486) h. (pp. 485–486) i. (pp. 18–20, §2.4; pp. 485–486) j. (pp. 485–486) k. (pp. 9–11 and 18–20) l. (pp. 9–10 and 485–486) m. (pp. 18–20, §2.4; pp. 485–486, §14.1) Hastie, T., Tibshirani, R. & Friedman, J. (2009). The Elements of Statistical Learning. Springer. https://doi.org/10.1007/978-0-387-84858-7
  2. ^ a b c d e f g h i j a. (Ch. 2, §2.1.4, pp. 26–27) b. (Ch. 2, §2.1.4, p. 26) c. (Ch. 2, §2.1.4, pp. 26–27) d. (Ch. 2, §2.1.5, pp. 28–29) e. (Ch. 2, §2.1.4, p. 28) f. (Ch. 2, §2.1.4, pp. 26–27; Ch. 12, §12.1, p. 496) g. (Ch. 2, §2.1.4, pp. 26–28) h. (Ch. 2, §2.1.5, pp. 28–29) i. (Ch. 2, pp. 26–29) j. (Ch. 2, §2.1.4–§2.1.5, pp. 26–29) James, G., Witten, D., Hastie, T. & Tibshirani, R. (2021). An Introduction to Statistical Learning: with Applications in R (2nd ed.). Springer, New York. https://doi.org/10.1007/978-1-0716-1418-1
Cite this page
Plain text
StatWiki (2026). "Supervised learning." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/supervised-learning.html
BibTeX
@misc{statwiki_supervised_learning,
  author = {{StatWiki}},
  title = {{Supervised learning}},
  year = {2026},
  url = {https://www.statwiki.io/articles/supervised-learning.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}