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

Function rmse

machine_learning/scoring_functions.py:62–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

60
61# Root Mean Squared Error
62def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected