File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import urllib
1010import threading
1111import multiprocessing
12+ import numpy as np
1213
1314
1415class 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 } "
You can’t perform that action at this time.
0 commit comments