test(e2e): fix S.1.1 expected values to match RegressionMetrics rounding
RegressionMetrics rounds every metric to 2 decimals (documented in lib.md); the old test compared against unrounded closed-form values with a 1e-6 tolerance, which the rewritten activity can no longer satisfy. Round the expected values the same way before comparing. Confirmed via real Docker-backed Postgres/MinIO/Mongo + Temporal test environment: all 4 simple_metrics e2e scenarios pass.
This commit is contained in:
@@ -140,7 +140,8 @@ async def test_simple_metrics_happy_path_persists_all_metrics_and_columns(
|
||||
prediction/target pair set and written one row per metric. Every column
|
||||
expected by ``sientia_data.simple_metrics`` must be populated (except the
|
||||
nullable ``timestamp`` column) and the numerical values must match
|
||||
closed-form expectations.
|
||||
closed-form expectations, rounded to 2 decimals as ``RegressionMetrics``
|
||||
persists them (see ``sientia_model/metrics/regression.py``).
|
||||
"""
|
||||
client = temporal_test_env.client
|
||||
model_id = 511
|
||||
@@ -154,13 +155,13 @@ async def test_simple_metrics_happy_path_persists_all_metrics_and_columns(
|
||||
]
|
||||
diffs = [target - prediction for prediction, target in pairs]
|
||||
n = len(diffs)
|
||||
expected_rmse = math.sqrt(sum(d * d for d in diffs) / n)
|
||||
expected_mse = sum(d * d for d in diffs) / n
|
||||
expected_mae = sum(abs(d) for d in diffs) / n
|
||||
expected_rmse = round(math.sqrt(sum(d * d for d in diffs) / n), 2)
|
||||
expected_mse = round(sum(d * d for d in diffs) / n, 2)
|
||||
expected_mae = round(sum(abs(d) for d in diffs) / n, 2)
|
||||
target_mean = sum(t for _, t in pairs) / n
|
||||
ss_res = sum((target - prediction) ** 2 for prediction, target in pairs)
|
||||
ss_tot = sum((t - target_mean) ** 2 for _, t in pairs)
|
||||
expected_r2 = 1.0 - (ss_res / ss_tot)
|
||||
expected_r2 = round(1.0 - (ss_res / ss_tot), 2)
|
||||
|
||||
_seed_predictions_and_targets(postgres_engine, model_id=model_id, pairs=pairs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user