From 80bdfbb9f9f828f39633e6f59deb7559340b4700 Mon Sep 17 00:00:00 2001 From: himangSharatun Date: Sat, 18 Nov 2017 10:34:07 +0700 Subject: [PATCH] add mean bias deviation in scoring functions --- machine_learning/scoring_functions.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 machine_learning/scoring_functions.py diff --git a/machine_learning/scoring_functions.py b/machine_learning/scoring_functions.py old mode 100644 new mode 100755 index 4204716cd..861d45c1f --- a/machine_learning/scoring_functions.py +++ b/machine_learning/scoring_functions.py @@ -1,4 +1,4 @@ -import numpy +import numpy as np """ Here I implemented the scoring functions. MAE, MSE, RMSE, RMSLE are included. @@ -41,7 +41,7 @@ def rmse(predict, actual): actual = np.array(actual) difference = predict - actual - square_diff = np.square(dfference) + square_diff = np.square(difference) mean_square_diff = square_diff.mean() score = np.sqrt(mean_square_diff) return score @@ -61,3 +61,18 @@ def rmsle(predict, actual): score = np.sqrt(mean_square_diff) return score + +#Mean Bias Deviation +def mbd(predict, actual): + predict = np.array(predict) + actual = np.array(actual) + + difference = predict - actual + numerator = np.sum(difference) / len(predict) + denumerator = np.sum(actual) / len(predict) + print str(numerator) + print str(denumerator) + + score = float(numerator) / denumerator * 100 + + return score \ No newline at end of file