Skip to content

Commit 028d23e

Browse files
authored
Merge pull request #46 from midaa1/metrics-modification
Fixing the precision and accuracy calculations for X and Y axes
2 parents d61e716 + fb61b2c commit 028d23e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app/services/metrics.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ def func_precision_x(group):
1111
Returns:
1212
float: The precision value.
1313
"""
14-
return np.sqrt(np.sum(np.square([group["Predicted X"], group["True X"]])))
15-
14+
return np.sqrt(
15+
np.mean(np.square(group["Predicted X"] - np.mean(group["Predicted X"])))
16+
)
1617

1718
def func_presicion_y(group):
1819
"""
@@ -24,7 +25,9 @@ def func_presicion_y(group):
2425
Returns:
2526
float: The precision value.
2627
"""
27-
return np.sqrt(np.sum(np.square([group["Predicted Y"], group["True Y"]])))
28+
return np.sqrt(
29+
np.mean(np.square(group["Predicted Y"] - np.mean(group["Predicted Y"])))
30+
)
2831

2932

3033
def func_accuracy_x(group):
@@ -37,7 +40,9 @@ def func_accuracy_x(group):
3740
Returns:
3841
float: The accuracy value.
3942
"""
40-
return np.sqrt(np.sum(np.square([group["True X"] - group["Predicted X"]])))
43+
44+
return np.sqrt(np.mean(np.square(group["True X"] - group["Predicted X"])))
45+
4146

4247

4348
def func_accuracy_y(group):
@@ -50,4 +55,5 @@ def func_accuracy_y(group):
5055
Returns:
5156
float: The accuracy value.
5257
"""
53-
return np.sqrt(np.sum(np.square([group["True Y"] - group["Predicted Y"]])))
58+
return np.sqrt(np.mean(np.square(group["True Y"] - group["Predicted Y"])))
59+

0 commit comments

Comments
 (0)