From ffcac582ce01065a907f03f179cb4076fa531e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cervenka?= Date: Mon, 4 Apr 2022 14:58:32 +0200 Subject: [PATCH] std in api response (#32) --- setup.cfg | 2 +- src/epstats/server/res.py | 7 +++++++ tests/epstats/server/test_api_evaluate.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bbb05e3..b0cbe21 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ep-stats -version = 1.1.2 +version = 1.2.0 description = Statistical package to evaluate ab tests in experimentation platform. long_description = file: README.md long_description_content_type = text/markdown diff --git a/src/epstats/server/res.py b/src/epstats/server/res.py index d37ea23..32fdb59 100644 --- a/src/epstats/server/res.py +++ b/src/epstats/server/res.py @@ -22,6 +22,9 @@ class MetricStat(BaseModel): description="""Nominator and denominator to calculate the mean are given in metric definition. `mean = nominator / denominator`.""", ) + std: float = Field( + title="Metric Standard Deviation", + ) sum_value: float = Field( title="Metric Value", description="""Value of the metric, it is given by the @@ -54,6 +57,7 @@ def from_df(df: pd.DataFrame): exp_variant_id=r["exp_variant_id"], diff=r["diff"], mean=r["mean"], + std=r["std"], sum_value=r["sum_value"], p_value=r["p_value"], confidence_interval=r["confidence_interval"], @@ -209,6 +213,7 @@ class Config: "exp_variant_id": "a", "diff": 0, "mean": 0.23809523809523808, + "std": 2.1, "sum_value": 5, "p_value": 1, "confidence_interval": 1.1432928868841614, @@ -218,6 +223,7 @@ class Config: "exp_variant_id": "b", "diff": 0.13076923076923078, "mean": 0.2692307692307692, + "std": 1.422, "sum_value": 7, "p_value": 1, "confidence_interval": 1.2327467657322932, @@ -227,6 +233,7 @@ class Config: "exp_variant_id": "c", "diff": 0.26, "mean": 0.3, + "std": 0.232, "sum_value": 9, "p_value": 1, "confidence_interval": 1.352808784877644, diff --git a/tests/epstats/server/test_api_evaluate.py b/tests/epstats/server/test_api_evaluate.py index b244f60..f60f64a 100644 --- a/tests/epstats/server/test_api_evaluate.py +++ b/tests/epstats/server/test_api_evaluate.py @@ -283,6 +283,7 @@ def assert_experiment(target, test_dao: TestDao, expected_metrics: int, expected "exp_variant_id": [], "diff": [], "mean": [], + "std": [], "sum_value": [], "p_value": [], "confidence_interval": [],