16
16
17
17
# Mean Absolute Error
18
18
def mae (predict , actual ):
19
+ """
20
+ Examples(rounded for precision):
21
+ >>> actual = [1,2,3];predict = [1,4,3]
22
+ >>> np.around(mae(predict,actual),decimals = 2)
23
+ 0.67
24
+
25
+ >>> actual = [1,1,1];predict = [1,1,1]
26
+ >>> mae(predict,actual)
27
+ 0.0
28
+ """
19
29
predict = np .array (predict )
20
30
actual = np .array (actual )
21
31
@@ -27,6 +37,16 @@ def mae(predict, actual):
27
37
28
38
# Mean Squared Error
29
39
def mse (predict , actual ):
40
+ """
41
+ Examples(rounded for precision):
42
+ >>> actual = [1,2,3];predict = [1,4,3]
43
+ >>> np.around(mse(predict,actual),decimals = 2)
44
+ 1.33
45
+
46
+ >>> actual = [1,1,1];predict = [1,1,1]
47
+ >>> mse(predict,actual)
48
+ 0.0
49
+ """
30
50
predict = np .array (predict )
31
51
actual = np .array (actual )
32
52
@@ -39,6 +59,16 @@ def mse(predict, actual):
39
59
40
60
# Root Mean Squared Error
41
61
def rmse (predict , actual ):
62
+ """
63
+ Examples(rounded for precision):
64
+ >>> actual = [1,2,3];predict = [1,4,3]
65
+ >>> np.around(rmse(predict,actual),decimals = 2)
66
+ 1.15
67
+
68
+ >>> actual = [1,1,1];predict = [1,1,1]
69
+ >>> rmse(predict,actual)
70
+ 0.0
71
+ """
42
72
predict = np .array (predict )
43
73
actual = np .array (actual )
44
74
@@ -51,6 +81,16 @@ def rmse(predict, actual):
51
81
52
82
# Root Mean Square Logarithmic Error
53
83
def rmsle (predict , actual ):
84
+ """
85
+ Examples(rounded for precision):
86
+ >>> actual = [10,10,30];predict = [10,2,30]
87
+ >>> np.around(rmsle(predict,actual),decimals = 2)
88
+ 0.75
89
+
90
+ >>> actual = [1,1,1];predict = [1,1,1]
91
+ >>> rmsle(predict,actual)
92
+ 0.0
93
+ """
54
94
predict = np .array (predict )
55
95
actual = np .array (actual )
56
96
@@ -68,15 +108,29 @@ def rmsle(predict, actual):
68
108
69
109
# Mean Bias Deviation
70
110
def mbd (predict , actual ):
111
+ """
112
+ This value is Negative, if the model underpredicts,
113
+ positive, if it overpredicts.
114
+
115
+ Example(rounded for precision):
116
+
117
+ Here the model overpredicts
118
+ >>> actual = [1,2,3];predict = [2,3,4]
119
+ >>> np.around(mbd(predict,actual),decimals = 2)
120
+ 50.0
121
+
122
+ Here the model underpredicts
123
+ >>> actual = [1,2,3];predict = [0,1,1]
124
+ >>> np.around(mbd(predict,actual),decimals = 2)
125
+ -66.67
126
+ """
71
127
predict = np .array (predict )
72
128
actual = np .array (actual )
73
129
74
130
difference = predict - actual
75
131
numerator = np .sum (difference ) / len (predict )
76
132
denumerator = np .sum (actual ) / len (predict )
77
- print (numerator )
78
- print (denumerator )
79
-
133
+ # print(numerator, denumerator)
80
134
score = float (numerator ) / denumerator * 100
81
135
82
136
return score
0 commit comments