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

Function mbd

machine_learning/scoring_functions.py:109–135  ·  view source on GitHub ↗

This value is Negative, if the model underpredicts, positive, if it overpredicts. Example(rounded for precision): Here the model overpredicts >>> actual = [1,2,3];predict = [2,3,4] >>> float(np.around(mbd(predict,actual),decimals = 2)) 50.0 Here the model underpre

(predict, actual)

Source from the content-addressed store, hash-verified

107
108# Mean Bias Deviation
109def mbd(predict, actual):
110 """
111 This value is Negative, if the model underpredicts,
112 positive, if it overpredicts.
113
114 Example(rounded for precision):
115
116 Here the model overpredicts
117 >>> actual = [1,2,3];predict = [2,3,4]
118 >>> float(np.around(mbd(predict,actual),decimals = 2))
119 50.0
120
121 Here the model underpredicts
122 >>> actual = [1,2,3];predict = [0,1,1]
123 >>> float(np.around(mbd(predict,actual),decimals = 2))
124 -66.67
125 """
126 predict = np.array(predict)
127 actual = np.array(actual)
128
129 difference = predict - actual
130 numerator = np.sum(difference) / len(predict)
131 denumerator = np.sum(actual) / len(predict)
132 # print(numerator, denumerator)
133 score = float(numerator) / denumerator * 100
134
135 return score
136
137
138def manual_accuracy(predict, actual):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected