Examples(rounded for precision): >>> float(np.around(rmsle(predict=[10, 2, 30], actual=[10, 10, 30]), decimals=2)) 0.75 >>> float(rmsle(predict=[1, 1, 1], actual=[1, 1, 1])) 0.0
(predict, actual)
| 82 | |
| 83 | # Root Mean Square Logarithmic Error |
| 84 | def rmsle(predict, actual): |
| 85 | """ |
| 86 | Examples(rounded for precision): |
| 87 | >>> float(np.around(rmsle(predict=[10, 2, 30], actual=[10, 10, 30]), decimals=2)) |
| 88 | 0.75 |
| 89 | |
| 90 | >>> float(rmsle(predict=[1, 1, 1], actual=[1, 1, 1])) |
| 91 | 0.0 |
| 92 | """ |
| 93 | predict = np.array(predict) |
| 94 | actual = np.array(actual) |
| 95 | |
| 96 | log_predict = np.log(predict + 1) |
| 97 | log_actual = np.log(actual + 1) |
| 98 | |
| 99 | difference = log_predict - log_actual |
| 100 | square_diff = np.square(difference) |
| 101 | mean_square_diff = square_diff.mean() |
| 102 | |
| 103 | score = np.sqrt(mean_square_diff) |
| 104 | |
| 105 | return score |
| 106 | |
| 107 | |
| 108 | # Mean Bias Deviation |
nothing calls this directly
no outgoing calls
no test coverage detected