Hello and welcome to your first lesson in our journey through machine learning and deep learning. Because you're interested in mastering the core mechanics of these fields—perhaps even to teach them yourself one day—we will start by building a rigorous, formal foundation. This first lesson is about establishing the "grammar" of supervised learning, which will allow us to discuss why and how models work, not just what they do.
Today, we will achieve the first learning outcome of the course: to formalize supervised learning as a function approximation problem. We will define the essential components of this framework, including the roles of training data and the underlying, true data distribution. By the end of this lesson, you will understand how the practical task of 'learning from data' is structured as a well-defined mathematical problem involving functions, probabilities, and optimization.
From Programming to Learning
In traditional programming, a developer writes explicit rules to transform input data into a desired output. Machine learning turns this on its head: we provide the algorithm with examples of data and the corresponding desired outputs, and the algorithm's job is to learn the rules itself. This learned set of rules is our "model" or "program."
Let's begin by watching a short segment from a lecture by Kilian Weinberger at Cornell University, which illustrates this fundamental distinction.
Lecture 1 "Supervised Learning Setup" -Cornell CS4780 Machine Learning for Decision Making SP17
This video provides a clear conceptual starting point for what makes machine learning different from traditional computer science.
Please watch the segment from the beginning. Focus on the comparison between writing an MP3 player (where the rules are known) and diagnosing a disease from a scan (where the rules must be learned). Pay attention to the introduction of "training" and "testing."
This training/testing paradigm is the cornerstone of supervised learning. Let's formalize the setup.
The Formal Setup of Supervised Learning
In supervised learning, we start with a dataset, which we'll denote as . This dataset consists of pairs of observations:
- Each is an input or feature vector from an input space . For example, could be , representing a vector with numerical features (like a patient's age, height, and blood pressure).
- Each is the corresponding output or label from an output space . The nature of defines the type of problem:
- Regression: is a set of continuous values (e.g., for predicting house prices).
- Classification: is a discrete set of categories (e.g., for spam detection, or for image classification).
The most crucial assumption in this framework is that our data points are independent and identically distributed (i.i.d.) samples drawn from a true, but unknown, joint probability distribution . This distribution represents the underlying process generating the data—the "real world" we are trying to model. The data we have, , is our training sample from this world. Our goal is to perform well on future samples from this same world, which we can call the test distribution.
To solidify these initial concepts, let's return to the Cornell lecture video.
Lecture 1 "Supervised Learning Setup" -Cornell CS4780 Machine Learning for Decision Making SP17
This part of the video formally introduces the dataset \mathcal{D}, the i.i.d. assumption, and the different types of supervised learning tasks based on the output space \mathcal{Y}.
Please watch from this section on the supervised learning setup, and then the following segment on task examples.
The Goal: Minimizing Risk
Our objective is to use the training data to find a function, , called a hypothesis or predictor, that makes accurate predictions on new, unseen data drawn from .
To formalize "accurate," we first need to define a loss function, , which quantifies the penalty for a single incorrect prediction. For example, in regression, a common choice is the squared error: , where is our prediction.
While the loss tells us how we did on one example, we need a way to evaluate the hypothesis as a whole. The ultimate measure of a hypothesis's quality is its risk, also known as the generalization error. The risk is the expected loss over the true data-generating distribution .
This is our gold standard for evaluation. It measures the average performance of our hypothesis on all possible data, weighted by its probability of occurrence.
The following video from a Bloomberg lecture series on Statistical Learning Theory provides an excellent walkthrough of these ideas.
3. Introduction to Statistical Learning Theory
This video defines the concepts of a loss function and risk, which are central to our formalization.
Watch the segment from here, which introduces the idea of evaluating a decision function as a whole and formalizes it as the risk, or expected loss.
The Optimal Predictor: The Bayes Function
If we knew the true distribution , what would be the best possible hypothesis? This is the Bayes predictor, denoted . It is the function that minimizes the risk over the space of all possible functions.
The risk of this optimal function, , is called the Bayes risk. It represents the irreducible error for the problem—the error that remains even with a perfect model, due to inherent randomness or noise in the data-generating process itself.
For a given loss function, the form of the Bayes predictor is often intuitive. For squared error loss in regression, turns out to be the conditional expectation of the output given the input, . This is a powerful result that connects the statistical properties of the data to the optimal prediction strategy.
Let's watch the next segment of the Bloomberg video to see this explained.
3. Introduction to Statistical Learning Theory
This part defines the Bayes decision function and shows its specific form for two common scenarios: regression with squared error and classification with 0-1 loss.
Watch the segment from this part. The derivation for least squares regression is particularly insightful and leverages concepts from probability you are familiar with.
This formally frames our goal: supervised learning is a function approximation problem where we try to find a hypothesis that is a good approximation of the unknown Bayes predictor .
The Method: Empirical Risk Minimization
There's a major challenge: we cannot calculate the true risk because we do not know the true distribution .
Instead, we can use our training data to compute an approximation called the empirical risk, . This is simply the average loss of our hypothesis on the training data.
The Law of Large Numbers tells us that for any fixed hypothesis , as our sample size grows, the empirical risk converges to the true risk (). This suggests a natural learning strategy: Empirical Risk Minimization (ERM). We can try to find the hypothesis that minimizes the empirical risk on our training data.
However, naively minimizing the training error can be a trap. If we search for a function in a too-large, unrestricted space, we can easily find a hypothesis that perfectly "memorizes" the training data but fails spectacularly on new data. This phenomenon is called overfitting.
The solution is to not search over all possible functions, but to restrict our search to a predefined set of functions called the hypothesis space, denoted by a script . This could be the set of all linear functions, all polynomials up to degree 3, or all neural networks with a specific architecture. By choosing , we embed our assumptions about the problem's structure, aiming for functions that generalize well. This leads to the principle of Constrained Empirical Risk Minimization.
The following video segments will guide you through the introduction of empirical risk, the problem of overfitting, and the solution of using a constrained hypothesis space.
3. Introduction to Statistical Learning Theory
These segments connect the theoretical concept of risk to the practical approach of using training data, and introduce the crucial ideas of overfitting and hypothesis spaces.
First, watch from this part, which introduces empirical risk and demonstrates how ERM can lead to overfitting. Then, watch the next segment from here, which presents constrained ERM within a hypothesis space as the remedy.
A Deeper Look: The Sources of Error
We can now see that the total error of our final learned function, , comes from two distinct sources. Let's formalize this.
-
Approximation Error (or Bias): This error arises from our choice of hypothesis space . Even the best possible function within our chosen space, , might still be a poor approximation of the true Bayes predictor . If is too simple (e.g., trying to model a complex, non-linear phenomenon with only linear functions), our approximation error will be high.
-
Estimation Error (or Variance): This error arises from the fact that we are working with a finite training sample , not the full distribution . Our algorithm finds by minimizing the empirical risk, not the true risk. The difference between the performance of and the best-in-class function is the estimation error. This error is due to the "noise" and randomness in our specific, finite sample.
The diagram below visualizes this decomposition.

Understanding this trade-off is fundamental to machine learning. A very complex hypothesis space (like a very deep neural network) might have low approximation error but can suffer from high estimation error, as it might overfit the limited training data. A simple hypothesis space (like a linear model) may have low estimation error but suffer from high approximation error.
For a more detailed, mathematical treatment of these foundational concepts, you can refer to Chapter 3 of the Statistical Machine Learning notes by Louis Aslett. The sections on the problem setting, loss functions, and generalisation error are particularly relevant.
Chapter 3 Supervised Learning | Statistical Machine Learning
This text provides a rigorous, mathematical formalization of the concepts we've discussed. It serves as an excellent reference for the definitions of the problem setting, loss functions, and generalization error.
You can review the key definitions in the following sections: In "Problem setting," focus on the paragraphs that define the functional relationship and the assumption of an underlying data-generating measure. In "Loss functions," skim the list of common losses for regression and classification. In "Generalisation error," read the definition of generalization error and the distinction between training error and test error.
Conclusion
In this lesson, we have constructed the formal framework for supervised learning. We've moved from a general idea of "learning from examples" to a precise mathematical problem of function approximation.
Key Takeaways:
- Formal Problem: Supervised learning aims to find a function (hypothesis) that approximates an unknown target function, using a finite dataset of pairs.
- Underlying Distribution: We assume the data is sampled i.i.d. from a true but unknown probability distribution . This is our "test distribution."
- Goal (Risk): The ultimate goal is to find a hypothesis that minimizes the risk—the expected loss on unseen data from . The theoretical minimum risk is the Bayes risk, achieved by the Bayes predictor.
- Method (Empirical Risk): Since we cannot compute the true risk, we minimize the empirical risk—the average loss on our training data.
- The Trade-off (Hypothesis Space): To avoid overfitting, we constrain our search to a hypothesis space . This introduces a fundamental trade-off between approximation error (how well can model the true function) and estimation error (how well we can find the best function in with finite data).
In our next lesson, we will dive deeper into this trade-off by exploring the bias-variance decomposition. This will provide a powerful and concrete lens through which to analyze model complexity, overfitting, and underfitting, building directly on the foundational concepts of approximation and estimation error we established today.