Negative contributions.

This commit is contained in:
Casper 2019-04-06 20:48:13 +02:00
parent 8826d77647
commit 66c24a172d
No known key found for this signature in database
GPG Key ID: 289CA03790535054

View File

@ -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,