HOME Mathematics Computer Science
Mean Absolute Error
Prerequisites
Show All
Hide All
Mean
Show/Hide
﻿
Definition
The mean is a way of finding the average of a set of numbers. It is calculated by dividing the sum of the numbers by the count.
Example
Find the mean of the following numbers: [4, 7, 10]

sum = 4 + 7 + 10 = 21

count = 3

mean = 21 / 3 = 7

Mathematical Definition

LaTeX: \overline{x} = (\frac{1}{n})\sum_{i=1}^{n}(x_{i})
Code
import numpy

values = [4, 7, 10]

mean = numpy.average(values)
print(mean)

Notes
There are other types of mean, this one is called the 'Arithmetic Mean'. It is also called the 'Mathematical Expectation' and the 'Average'.

Mean Absolute Error
﻿
Definition
The mean absolute error (mae) is a metric for determining the similarity between two sets.

The error between two numbers is simply the difference between them. The absolute error is the absolute difference. To find the mean absolute error, you must find the absolute error between corresponding values in the sets, and then find the mean of those errors.
Example
Find the mean absolute error of the following two sets of numbers:

S1 = [2, 5, 9, 2]

S2 = [6, 3, 6, 1]

1. First we calculate the differences between these numbers:

D = [2 - 6, 5 - 3, 9 - 6, 2 - 1]

D = [-4, 2, 3, 1]

2. Now we must make these numbers absolute:

D = [4, 2, 3, 1]

3. Finally, we find the mean of these numbers:

mae = (4 + 2 + 3 + 1) / 4

mae = 10 / 4

mae = 2.5

Mathematical Definition

LaTeX: mae = (\frac{1}{n})\sum_{i=1}^{n}\left | y_{i} - x_{i} \right |
Code
import sklearn.metrics

S1 = [2, 5, 9, 2]
S2 = [6, 3, 6, 1]

mae = sklearn.metrics.mean_absolute_error(S1, S2)
print(mae)

Related