Home / Maths for AI / Symbols / Arithmetic and comparison

Absolute value

Say it: "the absolute value of x"

What it means

The distance of xx from zero, always zero or more: ∣−3∣=3|-3| = 3.

Example

∣−7∣=7,∣2−5∣=3|-7| = 7, \quad |2 - 5| = 3

Distance ignores direction.

In code

import numpy as np
print(np.abs([-7, 3, 2 - 5]))

Output

[7 3 3]

Where it appears in machine learning

Mean absolute error (MAE) averages the absolute differences between predictions and truth.

Related symbols

Learn it properly in the free lesson Numbers, Powers & Algebra, with practice questions that check your answers.