AI Glossary / Causal inference and experimentation / Intermediate
Evaluation function
Definition
An evaluation function is a rule or program that assigns a value to something being assessed. In classical AI search, especially game playing, it estimates how favorable a nonterminal state is when search cannot continue to the final outcome. In model evaluation, the phrase can instead mean code that calculates a performance score from predictions and reference data. The meaning depends on context; a state-value estimate and a measured test-set score are not interchangeable.
What it means
A search algorithm often cannot examine every possible future. It needs a practical estimate at the point where computation stops, so it scores features of the current state. That score helps compare available actions, even though it is not the actual final outcome. An evaluation function may be designed by people or learned from data. In a testing pipeline, by contrast, a function may implement a metric such as accuracy. Both produce assessments, but their inputs, uncertainty, and roles differ.
How it works
For depth-limited game search, define whose perspective the value represents, what features describe the state, and how those features map to a score. Search explores legal continuations until a terminal state or depth limit. True terminal outcomes receive their specified utilities; nonterminal cutoff states receive estimates from the evaluation function. Minimax then propagates values according to the players' choices. In a model-testing context, specify prediction type, reference labels, aggregation, and whether larger or smaller scores are better. Validate either function against the decision it is meant to support.
Three practical examples
- Game-playing AI: estimate a board position using material, mobility, and other relevant features when a full search is infeasible.
- Planning prototype: score candidate states using a clearly defined approximation of completion value and remaining effort.
- Model comparison: implement a documented scoring function that consistently evaluates held-out predictions, with tests for edge cases and score direction.
Think of it this way
Think of a traveler estimating the promise of a route from the landmarks currently visible. The estimate helps choose where to continue, but does not reveal everything beyond the horizon. This captures search evaluation. A separate travel review that measures the actual completed journey is closer to a test-set scoring function, which shows why the two uses of the term should be distinguished.
Worked example
Consider a simplified two-player search where higher scores favor player A. At the depth limit, a teaching evaluation function is E(s) = 3 times material advantage + mobility advantage. A nonterminal state with material advantage 2 and mobility advantage -1 receives E = 3 times 2 - 1 = 5. The weights and features are invented for illustration, not a recommended game engine.
Suppose action Left lets the opponent choose between cutoff states scored 5 and 1, while action Right lets the opponent choose between states scored 3 and 2. A minimax opponent chooses the lower score in each branch, giving Left a backed-up value of 1 and Right a value of 2. Player A therefore chooses Right under this search and evaluation. Simply selecting the largest leaf value, 5, would ignore the opponent's response. If the estimates overlook a decisive threat beyond the depth limit, the selected action can still be poor: correct search over inaccurate estimated values does not guarantee a good real outcome.
Illustrative case study
A fictional game-development team improves a search agent's evaluation function after noticing that it values short-term gains too highly. The team creates test positions containing delayed threats and compares the agent's chosen actions against reviewed continuations. It also measures the additional computation required by richer features. The revised function is assessed with the search depth and opponent behavior documented, because a score that helps one search configuration may behave differently when the computational budget changes.
Common misconceptions and mistakes
An evaluation function is not necessarily a probability, a true utility, or a training loss. Its numerical scale must be interpreted in context. A heuristic estimate at a cutoff is not automatically exact merely because the search algorithm is correct. In model evaluation, a score implementation can also be wrong because of reversed sign, mismatched label order, or inappropriate inputs. Using one composite value can hide tradeoffs among features, especially when their scales or weights have no defensible basis.
Business use
Use the term precisely when specifying an AI component. State what enters the function, what comes out, who benefits from a larger value, and how the output influences action or comparison. For search, evaluate decisions and outcomes under the intended computational budget. For model scoring, use held-out data and a metric that matches the task. Keep critical constraints explicit rather than assuming a weighted score will always enforce them. Version the function because changing its weights or logic changes what the system optimizes or reports.
People also ask
Must an evaluation function be handwritten?
No. It can be learned, although learned estimates still need validation.
Is a higher value always better?
No. The sign and perspective are part of the definition; some functions represent costs that should be minimized.
Is an evaluation metric the same thing?
A metric is a defined measure, while an evaluation function can be its implementation or, in search, a heuristic value estimator with a different purpose.
Check your understanding
Why does minimax choose Right even though Left contains a leaf scored 5?
Answer: The opponent can choose the less favorable continuation. Left's worst response scores 1, while Right's worst response scores 2, so Right has the stronger backed-up estimate for player A.
Related terms
- Minimax
- Depth-limited search
- Utility function
- Evaluation metric
- Horizon effect
- Model selection
- Heuristic evaluation
- value function
- scorer
- feature weighting
Learn next
Build a tiny game tree and assign clear terminal utilities and separate nonterminal estimates. Compare choosing the best visible leaf with backing up values through an opponent's choices. Then study how learned value functions are validated. For model-testing use, examine the distinction between a metric formula and the software interface that applies it.
More in Causal inference and experimentation
- Error rate - Error rate is the proportion of evaluated units counted as incorrect under a defined rule.
- Estimand - An estimand is the precise quantity that a study aims to learn about.
- Evaluation - Evaluation is the systematic assessment of an AI model, output, or complete system against defined purposes and criteria.
- Exact match - Exact match is an evaluation rule that gives credit only when a prediction equals an accepted reference answer under the specified comparison procedure.
- Experiment - An experiment is a planned investigation in which a researcher deliberately changes one or more conditions and observes the resulting outcomes.
- Extrinsic evaluation - Extrinsic evaluation assesses an AI component or output by measuring its effect on a downstream task or wider application.
Sources
UC Berkeley CS188, original course material on minimax and evaluation functions: https://inst.eecs.berkeley.edu/~cs188/textbook/games/minimax.html Scikit-learn, metrics and scoring guide: https://scikit-learn.org/stable/modules/model_evaluation.html Scikit-learn, check_scoring: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.check_scoring.html
Previous: Evaluation Bias Next: Evaluation machine learning pipeline