puqi commited on
Commit
20fb87c
·
1 Parent(s): daa5b98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -1
app.py CHANGED
@@ -57,4 +57,47 @@ data.model_names = ['const', 'mlr'] # add names of your models here
57
  preds = [const_pred_val, mlr_pred_val] # add your custom predictions here
58
  data.preds_val = dict(zip(data.model_names, preds))
59
 
60
- st.markdown('Streamlit c')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  preds = [const_pred_val, mlr_pred_val] # add your custom predictions here
58
  data.preds_val = dict(zip(data.model_names, preds))
59
 
60
+
61
+ data.reweight_target(data_split = 'val')
62
+ data.reweight_preds(data_split = 'val')
63
+ data.metrics_names = ['MAE', 'RMSE', 'R2', 'bias']
64
+ data.create_metrics_df(data_split = 'val')
65
+ %config InlineBackend.figure_format = 'retina'
66
+ letters = string.ascii_lowercase
67
+
68
+ # create custom dictionary for plotting
69
+ dict_var = data.metrics_var_val
70
+ plot_df_byvar = {}
71
+ for metric in data.metrics_names:
72
+ plot_df_byvar[metric] = pd.DataFrame([dict_var[model][metric] for model in data.model_names],
73
+ index=data.model_names)
74
+ plot_df_byvar[metric] = plot_df_byvar[metric].rename(columns = data.var_short_names).transpose()
75
+
76
+ # plot figure
77
+ fig, axes = plt.subplots(nrows = len(data.metrics_names), sharex = True)
78
+ for i in range(len(data.metrics_names)):
79
+ plot_df_byvar[data.metrics_names[i]].plot.bar(
80
+ legend = False,
81
+ ax = axes[i])
82
+ if data.metrics_names[i] != 'R2':
83
+ axes[i].set_ylabel('$W/m^2$')
84
+ else:
85
+ axes[i].set_ylim(0,1)
86
+
87
+ axes[i].set_title(f'({letters[i]}) {data.metrics_names[i]}')
88
+ axes[i].set_xlabel('Output variable')
89
+ axes[i].set_xticklabels(plot_df_byvar[data.metrics_names[i]].index, \
90
+ rotation=0, ha='center')
91
+
92
+ axes[0].legend(columnspacing = .9,
93
+ labelspacing = .3,
94
+ handleheight = .07,
95
+ handlelength = 1.5,
96
+ handletextpad = .2,
97
+ borderpad = .2,
98
+ ncol = 3,
99
+ loc = 'upper right')
100
+ fig.set_size_inches(7,8)
101
+ fig.tight_layout()
102
+
103
+ st.markdown('Streamlit k')