|
28 | 28 | # import warnings |
29 | 29 | from utils import generate_rainbow_colors |
30 | 30 | import webbrowser |
31 | | -# microchange2 to test the fork |
32 | 31 |
|
33 | 32 | # %% constants |
34 | 33 | tooltip_delay={'show': 750, 'hide': 0} |
@@ -84,7 +83,7 @@ def normalize_series(s, method='min-max'): |
84 | 83 | return (s - s_min)/(s_max - s_min) |
85 | 84 | elif method=='median': |
86 | 85 | return s/s.median() |
87 | | - elif method=='min': |
| 86 | + elif method=='mean': |
88 | 87 | return s/s.mean() |
89 | 88 | elif method=='z-score': |
90 | 89 | return (s - s.mean())/s.std() |
@@ -1371,16 +1370,21 @@ def ts_update(n, use_only_selected, |
1371 | 1370 |
|
1372 | 1371 | x = df.loc[sel_rows,p].copy() |
1373 | 1372 | weight = wdf.loc[i, 'weight'] |
| 1373 | + # the series is mirrorred if it should be minimized ... |
| 1374 | + if weight < 0: |
| 1375 | + x = x.max() - x + x.min() |
| 1376 | + weight = np.abs(weight) |
1374 | 1377 |
|
| 1378 | + # utitlity function |
1375 | 1379 | if wdf.loc[i, 'log10']: x=np.log10(x) |
1376 | 1380 |
|
1377 | | - norm_method = wdf.loc[i,'normalize'] |
1378 | | - x=normalize_series(x, method=norm_method) |
1379 | | - |
1380 | | - # to correctly hangle weights<0, i.e. parameters to be minimized |
1381 | | - x = x*np.sign(weight) |
1382 | | - cdf[p] = 100*np.abs(weight)*(x - x.min())/(x.max()-x.min())/ weight_sum |
| 1381 | + # to normalize |
| 1382 | + x=normalize_series(x, method=wdf.loc[i,'normalize']) |
| 1383 | + |
| 1384 | + # to calculate contribution of the parameter to the total score |
| 1385 | + cdf[p] = 100*weight*x/weight_sum |
1383 | 1386 | cdf[p] = cdf[p].round(1) |
| 1387 | + # adding the parameter's contribution to the total score |
1384 | 1388 | df.loc[sel_rows,'total score'] += cdf[p] |
1385 | 1389 |
|
1386 | 1390 | # df['total score'] = df['total score'].apply(round_to_sign_digits) |
|
0 commit comments