Examples(rounded for precision): >>> actual = [1,2,3];predict = [1,4,3] >>> float(np.around(rmse(predict,actual),decimals = 2)) 1.15 >>> actual = [1,1,1];predict = [1,1,1] >>> float(rmse(predict,actual)) 0.0
(predict, actual)
| 60 | |
| 61 | # Root Mean Squared Error |
| 62 | def rmse(predict, actual): |
| 63 | """ |
| 64 | Examples(rounded for precision): |
| 65 | >>> actual = [1,2,3];predict = [1,4,3] |
| 66 | >>> float(np.around(rmse(predict,actual),decimals = 2)) |
| 67 | 1.15 |
| 68 | |
| 69 | >>> actual = [1,1,1];predict = [1,1,1] |
| 70 | >>> float(rmse(predict,actual)) |
| 71 | 0.0 |
| 72 | """ |
| 73 | predict = np.array(predict) |
| 74 | actual = np.array(actual) |
| 75 | |
| 76 | difference = predict - actual |
| 77 | square_diff = np.square(difference) |
| 78 | mean_square_diff = square_diff.mean() |
| 79 | score = np.sqrt(mean_square_diff) |
| 80 | return score |
| 81 | |
| 82 | |
| 83 | # Root Mean Square Logarithmic Error |
nothing calls this directly
no outgoing calls
no test coverage detected