How does classic classifier inference work?
Welcome! I am glad you are here to learn about classifier inference.
To make sure we tailor this session perfectly to your goals, tell me a little bit about what you want to get out of this:
Are you interested in a high-level conceptual overview of how inference works, or are you looking for the technical and mathematical details behind how a model processes the input?
I want the technical and mathematical details
Since you want to dive straight into the technical and mathematical core, let's start by laying down a clear boundary line. To understand how a classifier works under the hood, we must first isolate the math of making predictions from the math of learning.
What is Machine Learning Inference?
Training vs. Inference
| Dimension | Training Phase | Inference Phase |
|---|---|---|
| Goal | Find optimal parameters | Predict label for new input |
| Parameters | Dynamic (constantly updated) | Static (frozen weights/biases) |
| Key Math | Backpropagation, Gradient Descent | Forward pass, Matrix multiplication |
| Compute | Extremely high (hours to weeks) | Low, high-speed (milliseconds) |
The Inference Mathematical Pipeline
Now that we have mapped out the overall pipeline, we can dive deep into the actual equations of that first step: the linear combination of inputs.
Continue to the linear combination step
Step 1: The Linear Combination
Now that we are focusing on the first stage of the pipeline, let's unpack how the model calculates its raw score, which is represented mathematically by the variable .
Now, let's plug these values into our linear equation to calculate our raw output score :
A positive raw score like suggests the model is leaning heavily toward classifying this email as spam. But to understand how this calculation behaves when we scale up to hundreds of features, we need to look at how this equation behaves as a dot product in high-dimensional space.
Continue to the high-dimensional dot product concept
The Geometric Meaning of the Dot Product
When we scale up from our spam example to models with hundreds of inputs, writing out long algebraic sums becomes incredibly messy. Mathematically, we can tidy up this operation by treating the feature inputs and the model weights as two distinct vectors in a multi-dimensional space, transforming the linear combination into a simple .
This geometric perspective is a powerful way to understand how classification models think. During the training phase, the model adjusts its weight vector to point directly toward the cluster of data points that represent a specific target class. When we run inference on a new input vector , the dot product acts as a similarity sensor. If the input data is structurally similar to what the model learned, the two vectors point in nearly the same direction. This yields a small angle, a high positive cosine, and a large raw score .
A static geometric vector representation showing a fixed weight vector in the first quadrant and an input vector in the second quadrant with their shortest angular arc.
I have set up an interactive simulation above to help you visualize this relationship. Drag the red input vector around to see how changing its direction relative to the model's learned weight vector directly controls the raw score . Once you get a feel for how this dot product measures structural alignment, we can explore how the model takes this unbounded raw score and translates it into a clean, bounded probability.
How does the model handle negative raw scores geometrically?
When the dot product results in a negative raw score, it tells us something fascinating about the spatial orientation: the input vector and the weight vector are pointing in fundamentally opposite directions.
The Geometry of Opposition
Geometrically, a negative raw score occurs when the spatial angle between our weight vector and our input vector is greater than . because the cosine of any obtuse angle is negative, the entire drops below zero.
In our email classifier, the weight vector points toward the ideal archetype of a spam email. If a new email vector points in the opposite direction, it means its features are structurally the opposite of spam. For instance, it might have zero occurrences of the word "free" and a very long, legitimate message body. The math registers this lack of alignment as a negative score, which is the model's way of saying there's strong evidence against the target class.
Now, whether our raw score is positive or negative, it is still just an unbounded number. To make a practical classification, we need to pass this score through an activation function to convert it into a clean probability.