Mean Absolute Error

MediumMachine LearningMathArray

Description

Given equal-length arrays yTrue and yPred, return the mean absolute error, rounded to 4 decimal places.

Examples

Input:yTrue = [1,2,3], yPred = [1,2,3]
Output:0
Explanation:

Averaging the absolute differences between predictions and targets gives 0.

Input:yTrue = [3,5,2], yPred = [2,5,4]
Output:1
Explanation:

Averaging the absolute differences between predictions and targets gives 1.

Input:yTrue = [0,0], yPred = [1,3]
Output:2
Explanation:

Averaging the absolute differences between predictions and targets gives 2.

Constraints

  • 1 ≤ yTrue.length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.