Objective functions
A scalar objective maps the specified decision variables to one numerical cost.
On this page 8 sections
01An objective turns a model-design goal into a scalar score#
An objective turns a model-design goal into a scalar score. Training compares parameter choices by this score and tries to make it smaller. You must decide what counts as an error and how errors are combined before an optimization method can help.
An objective assigns one numerical score to each decision. To minimize it, first state what you can adjust and how its costs combine.
Fixed data and cost coefficients stay fixed while decisions vary.
Adjust x and y. A squared x cost weighted by 7 and a squared y cost weighted by 4 give one total:
If two examples have losses 2 and 6, the sum objective is 8 while the mean objective is 4. They rank these parameter settings in the same order when the dataset is fixed, but their gradients have different scales. Read whether a task asks for a sum, mean, or additional penalty.
Adjust . The costs are times and times . Choose their total objective.
Show answer and explanation
Add the weighted costs.
02The same construction works for resource costs#
The same construction works for resource costs. Multiply each adjustable quantity by its stated unit cost, then add the contributions.
An objective describes how to score decisions. It does not yet tell you which decisions are allowed or how to find the best one.
Adjust job counts . Unit costs are fixed at and , respectively. Choose total cost.
Show answer and explanation
Sum cost × count.
03In a prediction error, the observed target is fixed data#
In a prediction error, the observed target is fixed data. Changing that target to make the score smaller changes the problem.
List the decision variables explicitly. A symbol appearing in a formula is not automatically adjustable.
Target is fixed. For loss , a draft adjusts x and t. Repair it.
Show answer and explanation
Only x varies; t stays 7.
04A training objective is a chosen proxy for what you care about#
A training objective is a chosen proxy for what you care about. Minimizing squared prediction error does not automatically guarantee calibrated probabilities, fairness, or good performance on new data. Those require their own definitions and evaluation.
Name the adjustable decisions, hold data fixed and combine the stated costs into one scalar.
- Express a scalar objective for specified decision variables.
Sources & further reading
- [1]Boyd & Vandenberghe §4.1.1 ↗Boyd & Vandenberghe §4.1.1 · Article