MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / rmsle

Function rmsle

machine_learning/scoring_functions.py:84–105  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

82
83# Root Mean Square Logarithmic Error
84def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected