Probabilistic Classification
Probabilistic Classification
1. From Point Predictions to General Predictions
A standard classifier receives an input record u and predicts one value for the target variable. This single predicted class is commonly written as v^.
Such a classifier is called a:
Point classifier
Point predictor
Deterministic classifier
A point classifier makes one specific guess, even when the available evidence is uncertain.
For example, a camera mounted on a vehicle might observe an object in the street. A point classifier may be forced to choose one class, such as pedestrian, even though the object could also be a scooter rider or bicyclist.
Point classification is useful when an application requires one actionable answer, but it does not communicate the classifier’s uncertainty.
2. List Classifiers
A classifier can provide more information by returning an ordered list of possible classes instead of only one class.
For example, the classifier might return:
Pedestrian
Person riding a scooter
Person riding a bicycle
The list is ordered according to the classifier’s confidence:
The first item is the most likely class.
The second item is the second-most likely class.
The third item is the third-most likely class.
The predictions can be written as v^top, v^second, and v^third.
Variable-Length and Fixed-Length Lists
A list classifier may produce:
A fixed number of guesses, such as the top three or top ten classes.
A variable number of guesses, depending on the classifier’s certainty.
For example:
If the classifier is highly confident that an object is a pedestrian, it may return only one class.
If the classifier is uncertain, it may return several plausible classes.
Applications of List Classification
List predictions are common in recommendation systems.
For example, an online retailer may use:
Recent browsing history
Previous purchases
Similar users’ behavior
Product characteristics
to produce a ranked list of products the user may be interested in.
The system might display the user’s top ten recommendations rather than claiming that one particular product is certainly the user’s next purchase.
Constructing a List Classifier Using Embeddings
Suppose a predictor produces an embedded prediction y^, and the target classes have embedded representatives:
A nearest-neighbor classifier normally returns the representative closest to y^.
A list classifier can instead return:
The closest representative
The second-closest representative
The third-closest representative
More generally, it can return the r closest representatives. Their ranking provides an ordered list of candidate classes.
3. Probabilistic Classifiers
A probabilistic classifier assigns a probability to every possible target class.
Instead of returning only a single class, it might output:
Pedestrian: probability 0.90
Scooter rider: probability 0.05
Bicyclist: probability 0.05
This output communicates both:
The classifier’s most likely prediction
The classifier’s uncertainty among alternative predictions
Probabilistic classification is widely used because many real-world decisions involve uncertainty.
Weather Forecast Example
Weather forecasts provide a familiar example. A forecast might state that the probability of rain is 0.15, or 15%.
For a target set containing rain and no rain:
P(rain)=0.15
P(no rain)=0.85
The probabilities describe the classifier’s belief about each possible outcome.
A probabilistic classifier predicts a probability distribution over the possible target classes rather than selecting only one class.
4. Probability Distributions on a Finite Target Set
Let the target set be V. A probability distribution on V is a function that assigns a real number to each class v∈V.
For every class, the assigned probability must satisfy:
Nonnegativity $$ P(v)\geq 0 $$
Normalization $$ \sum_{v\in\mathcal{V}}P(v)=1 $$
The probability P(v) represents the probability assigned to class v.
Vector Representation
Suppose the target set contains k classes:
The probabilities can be written as a k-dimensional vector:
where
The distribution constraints can be expressed in vector notation as:
where the inequality is interpreted element by element, and
where 1 is the vector containing only ones.
The second equation states that all probability entries sum to one.
Two Equivalent Views
A probability distribution can therefore be treated in two ways:
As a function mapping each class v to a probability P(v).
As a vector containing the probabilities associated with the ordered classes v1,…,vk.
Both representations are useful:
Function notation is convenient when discussing individual classes.
Vector notation is convenient for algebra and optimization.
5. The Output of a Probabilistic Classifier
A probabilistic classifier receives an input u and returns a predicted distribution p^ over V.
This can be written as:
The capital G denotes a classifier that operates on the original input space and produces a prediction over the target space.
Because p^ is itself a function, the classifier G returns a function. For a particular class vi, the predicted probability is:
or, equivalently,
This quantity represents the probability assigned to class vi for input u.
The notation is conceptually important:
G is a function that receives u.
G(u) is a probability distribution.
Evaluating G(u) at vi gives the probability of class vi.
Thus, a probabilistic classifier is a function that returns another function.
6. Relationship Between Point and Probabilistic Classifiers
Point classifiers and probabilistic classifiers can be converted into one another, although information may be lost in the process.
Converting a Point Classifier into a Probabilistic Classifier
Suppose a point classifier predicts v^. A corresponding probability distribution can be defined by assigning probability one to v^ and zero to every other class:
This is a valid probabilistic classifier, but it does not provide additional information. It simply represents complete certainty in the point prediction.
Converting a Probabilistic Classifier into a Point Classifier
Given a probability distribution p^, a point prediction can be obtained by selecting the most probable class:
This process is called maximum likelihood in this context.
It converts an uncertain probability distribution into one specific, actionable prediction.
Example: Carrying an Umbrella
Suppose a weather classifier predicts:
Probability of rain: 0.60
Probability of no rain: 0.40
A maximum-likelihood decision chooses rain, so the person carries an umbrella.
If the probabilities are reversed, the point prediction becomes no rain.
Maximum likelihood is only one possible decision rule. Different applications may use different thresholds or costs. For example, carrying an umbrella may be worthwhile even when the probability of rain is below $0.50 if avoiding rain is especially important.
Constructing a List from a Probability Distribution
A list classifier can be produced by sorting the target classes according to their predicted probabilities.
For example, if:
P(v2)=0.60
P(v1)=0.25
P(v3)=0.15
then the ranked list is:
v2
v1
v3
A probability distribution therefore contains enough information to produce:
A point prediction
An ordered list prediction
A complete description of uncertainty
7. Methods for Constructing Probabilistic Classifiers
Many standard classification methods can be extended to produce probability distributions.
Tree-Based Probabilistic Classifiers
A decision tree contains:
Internal nodes labeled by features and threshold values
Leaves containing predictions
For a point-based tree, each leaf contains a single class prediction.
For a probabilistic tree, each leaf contains a probability distribution over the classes.
When an input reaches a leaf, the classifier returns that leaf’s distribution.
For example, a leaf might contain:
Class A: 0.75
Class B: 0.25
This indicates that the inputs reaching that leaf have been associated more frequently with Class A than Class B.
Nearest-Neighbor Probabilistic Classifiers
A nearest-neighbor probabilistic classifier uses the classes of nearby training examples to estimate probabilities.
Given a query point x:
Find the k nearest training examples to x.
Count how many of those neighbors belong to each class.
Divide each class count by k.
Use the resulting fractions as the predicted probabilities.
If eight neighbors are used and:
Three are in the true class
Five are in the false class
then the predicted distribution is:
and
This distribution is the empirical distribution of the classes among the nearest neighbors.
Geometric Interpretation
Suppose the inputs have been embedded into R2, and each point is colored according to its class.
For a query point:
Identify its k nearest points.
Draw a neighborhood containing those points.
Count the colors within the neighborhood.
Convert the color proportions into class probabilities.
For example, with k=8:
Eight blue neighbors produce probability 1 for blue and 0 for red.
Four blue and four red neighbors produce probabilities 0.5 for each.
Two blue and six red neighbors produce probabilities 0.25 for blue and 0.75 for red.
The probabilities vary smoothly as the query point moves through regions containing different mixtures of classes.
Linear and Neural Probabilistic Classifiers
Probabilistic classifiers can also be built from:
Linear predictors
Neural network predictors
These models produce scores or other intermediate outputs that can be transformed into a probability distribution over the classes.
8. Evaluating List Classifiers
Evaluating a list classifier is more nuanced than evaluating a point classifier because the correct answer may appear at different positions in the list.
Suppose a test example has true class v, and the classifier returns:
v^top
v^second
v^third
Accuracy at Different List Ranks
One evaluation method measures how often the true class appears within the first r predictions.
For example:
The true class is the top prediction for 68% of test examples.
The true class appears among the top two predictions for 79% of examples.
The true class appears among the top three predictions for 85% of examples.
These are different accuracy measures:
Top-1 accuracy: the true class is the first guess.
Top-2 accuracy: the true class is among the first two guesses.
Top-3 accuracy: the true class is among the first three guesses.
Top-r accuracy cannot decrease as r increases, because including more guesses makes it easier for the correct class to appear in the list.
Rank-Based Scoring
Another evaluation method assigns a score based on the position of the correct class.
For a three-item list:
Correct class in first position: 3 points
Correct class in second position: 2 points
Correct class in third position: 1 point
Correct class absent from the list: 0 points
The scores are added across the test set.
This method rewards a classifier for ranking the correct class highly while still giving partial credit when the correct class appears lower in the list.
9. Evaluating Probabilistic Classifiers
Suppose a test set contains inputs and true target values:
For each input ui, the probabilistic classifier produces a distribution p^i.
A good probabilistic classifier should:
Assign high probability to the class that actually occurs.
Assign low probability to classes that do not occur.
Express high confidence when it is usually correct.
Express uncertainty when several outcomes are plausible.
Example: Weather Predictions
Suppose a classifier predicts the probability of rain for each day.
A well-calibrated pattern would be:
On days when it rains, the predicted probability of rain is generally high.
On days when it does not rain, the predicted probability of rain is generally low.
A classifier that always predicts 0.50 for rain may sometimes be correct, but it does not provide useful confidence information.
Evaluation must therefore consider the probability assigned to the actual outcome, not merely whether the most probable class was correct.
10. Likelihood
For each test example i, the probability assigned to the observed class is:
If the test examples are treated as independent, the probability of observing the entire sequence of target values is the product:
This quantity can be interpreted in two related ways:
As a probability, when focusing on the likelihood of observing the data.
As a likelihood, when focusing on how well the predicted distributions explain the data.
The likelihood is large when the classifier assigns high probabilities to the classes that actually occur.
Two classifiers can be compared by comparing their likelihoods:
Larger likelihood indicates a better match between the predicted distributions and the observed data.
Smaller likelihood indicates that the classifier assigned low probabilities to outcomes that occurred.
11. Log Likelihood and Negative Log Likelihood
Products of many probabilities can become extremely small and inconvenient to work with. Taking logarithms converts the product into a sum:
Because probabilities lie between zero and one, their logarithms are nonpositive. It is therefore common to use the negative log likelihood:
A good classifier has:
Large likelihood
Large log likelihood
Small negative log likelihood
A classifier is penalized heavily when it assigns a very small probability to an outcome that actually occurs.
Average Negative Log Likelihood
The total negative log likelihood grows as the number of test examples grows. To compare results across data sets of different sizes, the quantity is divided by n:
This is called the average negative log likelihood.
It is a standard performance metric for probabilistic classifiers.
A lower average negative log likelihood indicates that the classifier assigns higher probabilities, on average, to the observed outcomes.
12. The Best Constant Probabilistic Classifier
A useful theoretical question is:
If a classifier is not allowed to use the input u, which single probability distribution gives the best predictions?
Such a classifier is called a constant probabilistic classifier because it always returns the same distribution.
Suppose the observed target values are:
The classifier must choose one distribution p^ to minimize:
The optimal constant distribution is the empirical distribution of the observed data.
Define:
Then the best constant prediction is:
In words, the best constant probabilistic classifier assigns each class its observed frequency in the data.
Example
Suppose a data set contains:
60 examples of Class A
30 examples of Class B
10 examples of Class C
The best constant probabilistic classifier is:
Class A: 0.60
Class B: 0.30
Class C: 0.10
This is analogous to results for other loss functions:
The best constant predictor under squared loss is the mean.
The best constant predictor under absolute loss is the median.
The best constant probabilistic predictor under average negative log likelihood is the empirical distribution.
13. Cross Entropy
The average negative log likelihood can be rewritten by grouping together examples belonging to the same class.
Let:
and let qj be the empirical probability of class vj:
Let p^j be the predicted probability of class vj.
The average negative log likelihood becomes:
This quantity is called the cross entropy of p^ relative to q:
Here:
q is the empirical or true distribution of the observed classes.
p^ is the distribution produced by the classifier.
H(q,p^) measures how well p^ predicts data distributed according to q.
The grouping works because every example belonging to class vj contributes the same term log(p^j), and qj gives the fraction of examples in that class.
Interpretation
Cross entropy becomes small when:
The classifier gives high probability to frequent classes.
The classifier gives low probability to classes that rarely occur.
The predicted distribution closely matches the empirical distribution.
Cross entropy becomes large when the classifier assigns low probability to classes that occur frequently.
14. Entropy
When the predicted distribution and the empirical distribution are the same, the cross entropy becomes the entropy of the distribution.
For a distribution p:
Entropy measures the inherent uncertainty in a probability distribution.
A distribution concentrated almost entirely on one class has low entropy.
A distribution spread evenly across many classes has high entropy.
For example:
A distribution such as (1,0,0) has minimal uncertainty.
A uniform distribution over three classes, such as (31,31,31), has greater uncertainty.
Cross entropy and entropy are important in:
Information theory
Coding theory
Machine learning
Probabilistic modeling
For probabilistic classification, their main role is to analyze and optimize the average negative log likelihood.
15. Kullback–Leibler Divergence
The difference between cross entropy and entropy is called the Kullback–Leibler divergence, or KL divergence.
For distributions q and p:
Expanding the definitions gives:
The notation DKL(q∥p) emphasizes that the divergence is generally not symmetric. In general:
Why KL Divergence Helps with Optimization
Since:
and H(q) does not depend on the predicted distribution p, minimizing cross entropy with respect to p is equivalent to minimizing KL divergence:
The entropy term is simply a constant offset during this optimization.
Nonnegativity
KL divergence satisfies:
Equality holds when the two distributions are equal:
Thus, KL divergence measures how different the predicted distribution p is from the reference distribution q.
Derivation of Nonnegativity
Starting with:
The inequality:
holds for positive x.
Using x=qjpj gives:
Multiplying by qj and changing signs yields:
Summing over all classes:
Because both q and p are probability distributions:
Therefore:
and consequently:
The result also holds when some components of q are zero, using the standard convention that zero-probability terms contribute zero to the sum.
16. Why the Empirical Distribution Is Optimal
The average negative log likelihood is the cross entropy:
Using the KL divergence relationship:
The entropy H(q) is fixed because q is fixed. The only variable term is the KL divergence.
Since KL divergence is always nonnegative and reaches its minimum value of zero when:
the optimal constant probabilistic classifier is:
Therefore, the empirical distribution minimizes average negative log likelihood among all constant probabilistic classifiers.
The minimum cross entropy is then:
So the entropy of the empirical distribution is the lowest possible average negative log likelihood for a classifier that ignores the inputs.
17. Main Relationships
The central relationships among the different prediction types are:
A point classifier returns one class.
A list classifier returns several ranked classes.
A probabilistic classifier returns a probability distribution over all classes.
A point prediction can be extracted from a probabilistic prediction using maximum likelihood.
A ranked list can be extracted by sorting classes by probability.
A point classifier can be represented as a degenerate probabilistic classifier with probability one on its chosen class.
Probabilistic classifiers are evaluated using the probabilities assigned to the observed outcomes.
The standard evaluation measure is average negative log likelihood.
Average negative log likelihood is equivalent to cross entropy between the empirical distribution and the predicted distribution.
Cross entropy differs from entropy by the KL divergence.
KL divergence is nonnegative and is minimized when the predicted distribution equals the empirical distribution.
Consequently, the best constant probabilistic classifier is the empirical distribution of the target classes.

Ask anything
We've read this whole study set, so questions about it get the best answers.