Innings2
Powered by Innings 2

Glossary

Select one of the keywords on the left…

Introduction to AI > Minimize model errors with cost functions

Minimize model errors with cost functions

The learning process repeatedly alters a model until it can make high-quality estimates. To determine how well a model is performing, the learning process uses mathematics in the form of a cost function.

What is another name for a cost function?

Error, cost, and loss

In supervised learning, error, cost, and loss all refer to the number of mistakes that a model makes in predicting one or more labels.

Let's categorize these terms by their usage:

A measurement of prediction mistakes
How far off a model's estimates are
The difference between predicted and actual values
Terms that mean something different in machine learning
Used Interchangeably
Different Meaning

Cost Calculation Example

These three terms are used loosely in machine learning, which can cause some confusion. For the sake of simplicity, we use them interchangeably here. Cost is calculated through mathematics; it isn't a qualitative judgment.

If a model predicts a daily temperature of 40°F, but the actual value is 35°F, what is the error? °F

Goal of Cost Functions

Our goal is to have zero cost in theory
We aim for the lowest possible cost in practice
We always achieve perfect zero cost
How we calculate cost dictates what the model tries to learn

What is a cost function?

In supervised learning, a cost function is a small piece of code that calculates cost from:

A model's prediction
Random guesses
Only the training data
Historical data only

and the expected label (the correct answer).

Training Process

Final Considerations

During training, different cost functions can change how long training takes, or how well it works. Complete these key points:

  1. If the cost function states errors are , the optimizer makes small changes
  2. If the cost function returns values for certain mistakes, the optimizer works to avoid these mistakes
  3. There isn't a cost function
  4. Which cost function is best depends on what we're trying to achieve

Remember: We often need to experiment with cost functions to get a result we're happy with.