Examples(rounded for precision): >>> actual = [1,2,3];predict = [1,4,3] >>> float(np.around(mae(predict,actual),decimals = 2)) 0.67 >>> actual = [1,1,1];predict = [1,1,1] >>> float(mae(predict,actual)) 0.0
(predict, actual)
| 17 | |
| 18 | # Mean Absolute Error |
| 19 | def mae(predict, actual): |
| 20 | """ |
| 21 | Examples(rounded for precision): |
| 22 | >>> actual = [1,2,3];predict = [1,4,3] |
| 23 | >>> float(np.around(mae(predict,actual),decimals = 2)) |
| 24 | 0.67 |
| 25 | |
| 26 | >>> actual = [1,1,1];predict = [1,1,1] |
| 27 | >>> float(mae(predict,actual)) |
| 28 | 0.0 |
| 29 | """ |
| 30 | predict = np.array(predict) |
| 31 | actual = np.array(actual) |
| 32 | |
| 33 | difference = abs(predict - actual) |
| 34 | score = difference.mean() |
| 35 | |
| 36 | return score |
| 37 | |
| 38 | |
| 39 | # Mean Squared Error |
nothing calls this directly
no outgoing calls
no test coverage detected