Examples(rounded for precision): >>> actual = [1,2,3];predict = [1,4,3] >>> float(np.around(mse(predict,actual),decimals = 2)) 1.33 >>> actual = [1,1,1];predict = [1,1,1] >>> float(mse(predict,actual)) 0.0
(predict, actual)
| 38 | |
| 39 | # Mean Squared Error |
| 40 | def mse(predict, actual): |
| 41 | """ |
| 42 | Examples(rounded for precision): |
| 43 | >>> actual = [1,2,3];predict = [1,4,3] |
| 44 | >>> float(np.around(mse(predict,actual),decimals = 2)) |
| 45 | 1.33 |
| 46 | |
| 47 | >>> actual = [1,1,1];predict = [1,1,1] |
| 48 | >>> float(mse(predict,actual)) |
| 49 | 0.0 |
| 50 | """ |
| 51 | predict = np.array(predict) |
| 52 | actual = np.array(actual) |
| 53 | |
| 54 | difference = predict - actual |
| 55 | square_diff = np.square(difference) |
| 56 | |
| 57 | score = square_diff.mean() |
| 58 | return score |
| 59 | |
| 60 | |
| 61 | # Root Mean Squared Error |
nothing calls this directly
no outgoing calls
no test coverage detected