Skip to content

Commit 4ba5aa7

Browse files
authored
Merge pull request #8 from cssr-tools/TS_update
bugfix and prettify ts_update
2 parents e073d58 + 9369c91 commit 4ba5aa7

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

app.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
# import warnings
2929
from utils import generate_rainbow_colors
3030
import webbrowser
31-
# microchange2 to test the fork
3231

3332
# %% constants
3433
tooltip_delay={'show': 750, 'hide': 0}
@@ -84,7 +83,7 @@ def normalize_series(s, method='min-max'):
8483
return (s - s_min)/(s_max - s_min)
8584
elif method=='median':
8685
return s/s.median()
87-
elif method=='min':
86+
elif method=='mean':
8887
return s/s.mean()
8988
elif method=='z-score':
9089
return (s - s.mean())/s.std()
@@ -1371,16 +1370,21 @@ def ts_update(n, use_only_selected,
13711370

13721371
x = df.loc[sel_rows,p].copy()
13731372
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)
13741377

1378+
# utitlity function
13751379
if wdf.loc[i, 'log10']: x=np.log10(x)
13761380

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
13831386
cdf[p] = cdf[p].round(1)
1387+
# adding the parameter's contribution to the total score
13841388
df.loc[sel_rows,'total score'] += cdf[p]
13851389

13861390
# df['total score'] = df['total score'].apply(round_to_sign_digits)

0 commit comments

Comments
 (0)