From 66c24a172d17da9820be8ce88810f619519b3aa6 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sat, 6 Apr 2019 20:48:13 +0200 Subject: [PATCH] Negative contributions. --- server/nightr/app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/nightr/app.py b/server/nightr/app.py index b8f788b..b84d768 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -78,13 +78,13 @@ def probabilities(): prediction["night"] = not prediction["night"] # Calculate contributions of predictions - consensus_weight_sum = sum(p["weight"] for p in predictions if p["night"] == night) + weight_sum = sum(p["weight"] for p in predictions) for prediction in predictions: - # If this prediction agrees with the consensus it contributed - if prediction["night"] == night: - prediction["contribution"] = prediction["weight"] / consensus_weight_sum - else: - prediction["contribution"] = 0.0 + prediction["contribution"] = prediction["weight"] / weight_sum + + # If this prediction disagrees with the consensus it contributed negatively + if prediction["night"] != night: + prediction["contribution"] *= -1 return jsonify({ "predictions": predictions,