Maria Castellanos
commited on
Commit
·
718b39d
1
Parent(s):
ec86576
Fix eval for dummy
Browse files- evaluate.py +8 -14
- utils.py +1 -1
evaluate.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
from pathlib import Path
|
| 4 |
from typing import Optional
|
| 5 |
from about import (
|
| 6 |
-
ENDPOINTS, API,
|
| 7 |
submissions_repo,
|
| 8 |
results_repo_test,
|
| 9 |
results_repo_validation,
|
|
@@ -341,19 +341,13 @@ def calculate_metrics(
|
|
| 341 |
|
| 342 |
# calculate metrics with bootstrapping
|
| 343 |
bootstrap_df = bootstrap_metrics(y_pred_log, y_true_log, ept, n_bootstrap_samples=1000)
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
# Get a df with columns 'mean_MAE', 'std_MAE', ...
|
| 352 |
-
df_endpoint.columns = [
|
| 353 |
-
f'{i}_{j}' if i != '' else j for i, j in df_endpoint.columns
|
| 354 |
-
]
|
| 355 |
-
|
| 356 |
-
df_endpoint.rename(columns={'Endpoint_': 'Endpoint'}, inplace=True)
|
| 357 |
all_endpoint_results.append(df_endpoint)
|
| 358 |
|
| 359 |
df_results = pd.concat(all_endpoint_results, ignore_index=True)
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
from typing import Optional
|
| 5 |
from about import (
|
| 6 |
+
ENDPOINTS, API, METRICS,
|
| 7 |
submissions_repo,
|
| 8 |
results_repo_test,
|
| 9 |
results_repo_validation,
|
|
|
|
| 341 |
|
| 342 |
# calculate metrics with bootstrapping
|
| 343 |
bootstrap_df = bootstrap_metrics(y_pred_log, y_true_log, ept, n_bootstrap_samples=1000)
|
| 344 |
+
# Longer pivot alternative for the cases where all metric results are NaN, as pivot ignores those columns
|
| 345 |
+
grouped = bootstrap_df.groupby(["Endpoint", "Metric"])["Value"].agg(["mean", "std"])
|
| 346 |
+
df_unstacked = grouped.unstack(level="Metric")
|
| 347 |
+
df_reindexed = df_unstacked.reindex(columns=list(METRICS), level=1)
|
| 348 |
+
|
| 349 |
+
df_reindexed.columns = [f"{agg}_{metric}" for agg, metric in df_reindexed.columns]
|
| 350 |
+
df_endpoint = df_reindexed.reset_index()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
all_endpoint_results.append(df_endpoint)
|
| 352 |
|
| 353 |
df_results = pd.concat(all_endpoint_results, ignore_index=True)
|
utils.py
CHANGED
|
@@ -116,7 +116,7 @@ def metrics_per_ep(pred: np.ndarray,
|
|
| 116 |
else:
|
| 117 |
r2 = r2_score(true, pred)
|
| 118 |
|
| 119 |
-
if np.nanstd(pred)
|
| 120 |
spr = np.nan
|
| 121 |
ktau = np.nan
|
| 122 |
else:
|
|
|
|
| 116 |
else:
|
| 117 |
r2 = r2_score(true, pred)
|
| 118 |
|
| 119 |
+
if np.nanstd(pred) < 0.0001:
|
| 120 |
spr = np.nan
|
| 121 |
ktau = np.nan
|
| 122 |
else:
|