Skip to content

Commit 777d947

Browse files
authored
Merge pull request #210 from himangSharatun/master
add mean bias deviation in scoring functions
2 parents 7bb26e9 + 80bdfbb commit 777d947

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Diff for: machine_learning/scoring_functions.py

100644100755
+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import numpy
1+
import numpy as np
22

33
""" Here I implemented the scoring functions.
44
MAE, MSE, RMSE, RMSLE are included.
@@ -41,7 +41,7 @@ def rmse(predict, actual):
4141
actual = np.array(actual)
4242

4343
difference = predict - actual
44-
square_diff = np.square(dfference)
44+
square_diff = np.square(difference)
4545
mean_square_diff = square_diff.mean()
4646
score = np.sqrt(mean_square_diff)
4747
return score
@@ -61,3 +61,18 @@ def rmsle(predict, actual):
6161
score = np.sqrt(mean_square_diff)
6262

6363
return score
64+
65+
#Mean Bias Deviation
66+
def mbd(predict, actual):
67+
predict = np.array(predict)
68+
actual = np.array(actual)
69+
70+
difference = predict - actual
71+
numerator = np.sum(difference) / len(predict)
72+
denumerator = np.sum(actual) / len(predict)
73+
print str(numerator)
74+
print str(denumerator)
75+
76+
score = float(numerator) / denumerator * 100
77+
78+
return score

0 commit comments

Comments
 (0)