Fork me on GitHub

sklearn.metrics.median_absolute_error

sklearn.metrics.median_absolute_error(y_true, y_pred)[source]

Median absolute error regression loss

Read more in the User Guide.

Parameters:

y_true : array-like of shape = (n_samples)

Ground truth (correct) target values.

y_pred : array-like of shape = (n_samples)

Estimated target values.

Returns:

loss : float

A positive floating point value (the best value is 0.0).

Examples

>>> from sklearn.metrics import median_absolute_error
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> median_absolute_error(y_true, y_pred)
0.5
Previous