Error Function.
A mathematical measure of how far a model’s predictions deviate from the true values in the training data. The error function (also called the loss function or cost function) is the signal that drives all learning: training is the process of adjusting the model’s weights to minimize it. The choice of error function directly determines what the model optimizes for, which may or may not match what the business actually needs.
Also known as loss function, cost function, objective function
A working definition of the error function.
After a model makes a prediction, the error function compares that prediction to the correct answer and produces a single number representing how wrong the prediction was. If the model predicted a click probability of 0.8 and the actual outcome was no click, the error function produces a large number. If the prediction was 0.1 and the outcome was no click, it produces a small number. During training, the model uses this signal to adjust its weights in the direction that reduces future errors, a process called backpropagation.
Different tasks require different error functions. Regression tasks (predicting continuous values like revenue) typically use mean squared error, which penalizes large deviations heavily. Classification tasks (predicting categories like “will click” or “won’t click”) typically use cross-entropy loss, which is well-suited to probability outputs. Generative models use more complex error functions that assess the quality or likelihood of generated sequences.
The error function and the business objective are related but not identical. A model trained to minimize click-through rate prediction error may perform well by that measure but poorly on the actual business goal of revenue. This gap between what a model optimizes and what the business needs is one of the most common sources of AI deployment disappointment, and it begins with error function selection.
Why the error function is a business decision, not just a technical one.
Every AI model an agency deploys is optimizing for something. Understanding what it is optimizing for (the error function) versus what the client actually wants (the business objective) is the layer where most AI projects quietly fail. The model does exactly what it was trained to do. Whether that turns out to be what you needed depends entirely on the alignment between error function and goal.
Ad ranking models optimized for clicks can misalign with revenue. A programmatic model trained to minimize click prediction error will prioritize placements that generate clicks. If the client’s goal is ROAS, the model needs to be trained with an error function that penalizes errors in revenue prediction, not just click prediction. The difference in outcomes between click-optimized and revenue-optimized models can be substantial on the same campaign.
Brand safety models use error functions with asymmetric costs. For a brand safety classifier, a false negative (missing a harmful placement) is far more expensive than a false positive (blocking a safe placement). The error function should weight these errors accordingly. A standard equal-weight error function will produce a model that treats both error types as equivalent, which fails the brand safety use case.
It is a useful vendor accountability question. Asking a vendor what error function their model is trained on, and how it maps to your business objective, is a meaningful due diligence question. A clear, confident answer indicates a model designed with business alignment in mind. Vague or evasive answers suggest the model may have been optimized for benchmark metrics that do not reflect client outcomes.
What the error function looks like inside a working ad agency.
An agency builds a creative scoring model to predict which ad concepts will perform best for a retail client. The initial model uses mean squared error against engagement rate as its error function and produces predictions that correlate with likes and shares but not with the client’s actual KPI of in-store visits. The team redefines the target variable to in-store visit lift (sourced from the client’s foot traffic data) and retrains with the same architecture but a new error function. The retrained model produces recommendations that are less correlated with social engagement but 34% more predictive of in-store visit uplift. The change was entirely in the error function; nothing else in the model changed.
Learn how to align AI model objectives with actual business outcomes through The Creative Cadence Workshop.
The measurement and evaluation module covers how models are trained, what they optimize for, and how to identify when a vendor’s model is solving the wrong problem.
