Update percentage_error.py

This commit is contained in:
Sankari Karthik
2021-10-09 15:55:13 +05:30
committed by GitHub
parent 29190bfadb
commit 82015bf4d5

View File

@@ -5,6 +5,9 @@ def gen_func(maxValue=100, minValue=-100, format='string'):
observed_value = random.randint(minValue, maxValue)
exact_value = random.randint(minValue, maxValue)
if observed_value * exact_value < 0:
observed_value *= -1
error = (abs(observed_value - exact_value) / abs(exact_value)) * 100
error = round(error, 2)
@@ -20,5 +23,6 @@ def gen_func(maxValue=100, minValue=-100, format='string'):
return observed_value, exact_value, error
percentage_error = Generator("Percentage error", <id>, gen_func,
percentage_error = Generator(
"Percentage error", <id>, gen_func,
["maxValue=100", "minValue=-100"])