No history yet

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?

In machine learning, is the phase where a completed, fully trained model is put to work. The model is no longer adjusting its weights or learning from errors. Instead, it takes in new, unseen data points and runs them through its static mathematical formulas to calculate a prediction or a class label.

Training vs. Inference

It helps to think of the overall machine learning lifecycle as a two-stage process. During training, the algorithm is active, plastic, and highly compute-heavy. During inference, the algorithm is passive, static, and optimized for speed. Let's look at how their mathematical responsibilities differ:
DimensionTraining PhaseInference Phase
GoalFind optimal parametersPredict label for new input
ParametersDynamic (constantly updated)Static (frozen weights/biases)
Key MathBackpropagation, Gradient DescentForward pass, Matrix multiplication
ComputeExtremely high (hours to weeks)Low, high-speed (milliseconds)

The Inference Mathematical Pipeline

At its core, the entire process of passing data through a classifier to get a prediction is a deterministic pipeline. It always follows a three-step mathematical flow:
Xf(X)=WX+bzσ(z)pThresholdYX \xrightarrow{\quad f(X) = W \cdot X + b \quad} z \xrightarrow{\quad \sigma(z) \quad} p \xrightarrow{\quad \text{Threshold} \quad} Y

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 zz.

This step is where the model takes the raw, unlabeled inputs and combines them with its own learned knowledge. It uses a basic equation called a to transform your input data into a single numerical score.
z=WX+bz = W \cdot X + b
To understand how this operates in practice, let's look at a concrete example. Imagine we are running inference on a model that classifies whether an email is spam or not. Our feature vector XX contains just two numbers: the number of times the word "free" appears, and the total length of the email in characters.
X=[5120],W=[2.50.01],b=1.2X = \begin{bmatrix} 5 \\ 120 \end{bmatrix}, \quad W = \begin{bmatrix} 2.5 & -0.01 \end{bmatrix}, \quad b = -1.2

Now, let's plug these values into our linear equation to calculate our raw output score zz:

z=(2.5×5)+(0.01×120)+(1.2)z = (2.5 \times 5) + (-0.01 \times 120) + (-1.2)

A positive raw score like 10.110.1 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 .

z=WX+b=WXcos(θ)+bz = W \cdot X + b = \|W\| \|X\| \cos(\theta) + b

This geometric perspective is a powerful way to understand how classification models think. During the training phase, the model adjusts its weight vector WW to point directly toward the cluster of data points that represent a specific target class. When we run inference on a new input vector XX, 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 zz.

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 XX around to see how changing its direction relative to the model's learned weight vector WW directly controls the raw score zz. 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 XX and the weight vector WW are pointing in fundamentally opposite directions.

The Geometry of Opposition

Geometrically, a negative raw score zz occurs when the spatial angle θ\theta between our weight vector and our input vector is greater than 9090^\circ. because the cosine of any obtuse angle is negative, the entire drops below zero.

θ>90    cos(θ)<0    WX<0\theta > 90^\circ \implies \cos(\theta) < 0 \implies W \cdot X < 0

In our email classifier, the weight vector WW points toward the ideal archetype of a spam email. If a new email vector XX 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 zz 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.