Skip to content

Commit 72202a2

Browse files
committed
Cleaned up the output sent to PO as discussed with Stephane.
1 parent aec3390 commit 72202a2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

server.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import urllib
1010
import threading
1111
import multiprocessing
12+
import numpy as np
1213

1314

1415
class Server:
@@ -28,7 +29,7 @@ def __init__(self,
2829
self.auth = None
2930
if productopener_basic_auth_username != "" and productopener_basic_auth_password != "":
3031
self.auth = requests.auth.HTTPBasicAuth(productopener_basic_auth_username, productopener_basic_auth_password)
31-
self.estimation_version = 3
32+
self.estimation_version = 4
3233
self.impact_categories = ["EF single score",
3334
"Climate change"]
3435
self.stats = {
@@ -190,7 +191,16 @@ def _run_update_loop(self):
190191
try:
191192
impact = self._estimate_with_deadline(prod)
192193
self.logging.info(f"❤️ Computed {impact['impacts_geom_means']}")
193-
decoration["impact"] = impact
194+
max_confidence_idx = np.argmax(impact['confidence_score_distribution'])
195+
decoration["impact"] = {
196+
"likeliest_recipe": impact['recipes'][max_confidence_idx],
197+
"likeliest_impacts": {
198+
"Climate change": impact['impact_distributions']['Climate change'][max_confidence_idx],
199+
"EF single score": impact['impact_distributions']['EF single score'][max_confidence_idx],
200+
},
201+
"ef_single_score_log_stddev": np.std(np.log(impact['impact_distributions']['EF single score'])),
202+
"mass_ratio_uncharacterized": impact['uncharacterized_ingredients_mass_proportion']['impact']
203+
}
194204
self.stats["estimate_impacts_success"] += 1
195205
except Exception as e:
196206
error_desc = f"{e.__class__.__name__}: {e}"

0 commit comments

Comments
 (0)