From ff775c647254add9b09250aeee9ce778eba4f4c6 Mon Sep 17 00:00:00 2001 From: rakow Date: Mon, 15 Jul 2024 12:34:19 +0200 Subject: [PATCH] set eps in log loss --- matsim/calibration/run_simulations.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/matsim/calibration/run_simulations.py b/matsim/calibration/run_simulations.py index eb3c2a6..c077fae 100644 --- a/matsim/calibration/run_simulations.py +++ b/matsim/calibration/run_simulations.py @@ -97,13 +97,16 @@ def process_results(runs): accs = [accuracy_score(dfs.true_mode, dfs[col], sample_weight=dfs.weight) for col in pred_cols] accs_d = [accuracy_score(dfs.true_mode, dfs[col], sample_weight=dfs.weight * dists) for col in pred_cols] + # Compute likelihood with eps as 0.01% + eps = 0.0001 + result = [ - ("Log likelihood", -log_loss(y_true, y_pred, sample_weight=dfs.weight, normalize=False), - -log_loss(y_true, y_pred, sample_weight=dfs.weight * dists, normalize=False)), - ("Log likelihood (normalized)", -log_loss(y_true, y_pred, sample_weight=dfs.weight, normalize=True), - -log_loss(y_true, y_pred, sample_weight=dfs.weight * dists, normalize=True)), - ("Log likelihood (null)", -log_loss(y_true, y_null, sample_weight=dfs.weight, normalize=False), - -log_loss(y_true, y_null, sample_weight=dfs.weight * dists, normalize=False)), + ("Log likelihood", -log_loss(y_true, y_pred, sample_weight=dfs.weight, eps=eps, normalize=False), + -log_loss(y_true, y_pred, sample_weight=dfs.weight * dists, eps=eps, normalize=False)), + ("Log likelihood (normalized)", -log_loss(y_true, y_pred, sample_weight=dfs.weight, eps=eps, normalize=True), + -log_loss(y_true, y_pred, sample_weight=dfs.weight * dists, eps=eps, normalize=True)), + ("Log likelihood (null)", -log_loss(y_true, y_null, sample_weight=dfs.weight, eps=eps, normalize=False), + -log_loss(y_true, y_null, sample_weight=dfs.weight * dists, eps=eps, normalize=False)), ("Mean Accuracy", np.mean(accs), np.mean(accs_d)), ("Samples", len(dfs), sum(dists)), ("Runs", len(pred_cols), len(pred_cols))