-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
2182 lines (1883 loc) · 68.6 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_bootstrap_components as dbc
from util import display_figure,sync_checklists,parse_contents
from app_ins import App_ins
from app1 import App1,build_scatter,build_bump,build_heat_summary,build_line,build_fit,build_cor,build_line_raw,build_scatter_raw,build_acc_bar,build_heat_raw,build_dot,build_acc_raw,build_heat_consis
from app1_2 import App1_2,build_scatter_reg,build_bump_reg,build_heat_summary_reg,build_line_reg,build_fit_reg,build_cor_reg,build_scatter_raw_reg,build_line_raw_reg,build_acc_bar_reg,build_heat_raw_reg,build_dot_reg,build_acc_raw_reg,build_heat_consis_reg
from app2 import App2,build_scatter_clus,build_bump_clus,build_heat_summary_clus,build_line_clus,build_cor_clus,build_fit_clus,build_line_raw_clus,build_scatter_raw_clus,build_dot_clus,build_acc_bar_clus,build_heat_raw_clus,build_acc_raw_clus,build_heat_consis_clus
from app3 import App3,build_scatter_dr,build_bump_dr,build_heat_summary_dr,build_line_dr,build_cor_dr,build_fit_dr,build_line_raw_dr,build_scatter_raw_dr,build_acc_bar_dr,build_heat_raw_dr,build_dot_dr,build_acc_raw_dr,build_heat_consis_dr
from app3_2 import App3_2,build_line_knn,build_bump_knn,build_line_raw_knn,build_k_raw_knn,build_heat_knn
from home import Homepage
import plotly.express as px
from dash.dependencies import Input, Output, State, ClientsideFunction
from dash.exceptions import PreventUpdate
meths = ['SVM','LogisticRidge','LogisticLASSO', 'Tree','RF',
'XGB', 'deepLIFT (MLP)', 'Integrated Gradients (MLP)', 'Epsilon-LRP (MLP)',
'Guided Backpropagation (MLP)',
'Saliency Maps (MLP)','Occlusion (MLP)',
'Permutation (LogisticRidge)',
'Permutation (RF)',
'Permutation (XGB)',
'Permutation (MLP)',
'Shapley Value (LogisticRidge)' ,
'Shapley Value (RF)' ,
'Shapley Value (XGB)' ,
'Shapley Value (MLP)']
meths2 = ['SVM','Ridge','LASSO',
'Tree','RF','XGB',
'deepLIFT (MLP)', 'Integrated Gradients (MLP)', 'Epsilon-LRP (MLP)',
'Guided Backpropagation (MLP)',
'Saliency Maps (MLP)','Occlusion (MLP)',
'Permutation (Ridge)',
'Permutation (RF)',
'Permutation (XGB)' ,
'Permutation (MLP)',
'Shapley Value (Ridge)' ,
'Shapley Value (RF)' ,
'Shapley Value (XGB)',
'Shapley Value (MLP)' ]
# plot_summary_options = ['heatmap','line','bump','fit','dot','cor']
# plot_summary_new_options = ['line_new','bump_new','fit_new','dot_new','cor_new']
plot_raw_options = ['scatter_raw','line_raw','k_raw','heatmap_raw']
# plot_raw_options_knn = ['line_raw','k_raw']
plot_summary_options = ['heatmap','line','heat2','bump','fit']
plot_summary_new_options = ['line_new','heat2_new','bump_new']
plot_summary_options = {'heatmap':'Consistency heatmap across methods',
'line':'Consistency line plot within methods',
'heat2':'Consistency heatmap within methods',
'bump':'Bump plot of the most consistent methods across data sets',
'fit':'Scatter plot of consistency vs. prediction accuracy',
}
# dbc.themes.LUX
# dbc.themes.COSMO
# dbc.themes.FLATLY
# dbc.themes.JOURNAL
# dbc.themes.LUMEN
# dbc.themes.MINTY
# dbc.themes.SANDSTONE
# dbc.themes.SOLAR
# dbc.themes.UNITED
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.FLATLY])
app.title = "IMLreliability"
#app = dash.Dash(__name__, external_stylesheets=[dbc.themes.LUX])
#app = dash.Dash(__name__, external_stylesheets=[dbc.themes.CERULEAN])
#app = dash.Dash(__name__, external_stylesheets=[dbc.themes.UNITED])
app.config.suppress_callback_exceptions = True
app.layout = html.Div([
html.Div([ html.H3("Can We Trust Machine Learning Interpretations? A Reliability Study"),
html.H5("Luqin Gan, Genevera Allen")],style={'marginLeft': '10%', 'width': '90%'}),
dcc.Location(id = 'url', refresh = False),
html.Div(id = 'page-content')
])
server = app.server
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/instruction':
return App_ins()
if pathname == '/feature_importance_classification':
return App1()
if pathname == '/feature_importance_regression':
return App1_2()
if pathname == '/clustering':
return App2()
if pathname == '/dimension_reduction_clustering':
return App3()
if pathname == '/knn':
return App3_2()
else:
return Homepage()
@app.callback(
[
Output('method-select', 'value')],
[Input('url', 'pathname'),
Input('method-select_c', 'value')
],)
def dropdown_options(pathname,radio_value):
if pathname == '/feature_importance_classification':
if radio_value == 'Selected':
value = [['SVM', 'LogisticRidge',
'Permutation (LogisticRidge)',
'Shapley Value (LogisticRidge)' ,
'Tree','XGB','RF',
'Permutation (RF)',
'Shapley Value (RF)' ,
'Epsilon-LRP (MLP)',
'Guided Backpropagation (MLP)',
'Permutation (MLP)',
'Shapley Value (MLP)']]
elif radio_value == 'All':
# options = [{'label': x, 'value': x} for x in method_options]
value = meths,
elif radio_value == 'Model Specific':
# options = [{'label': x, 'value': x} for x in method_options]
value = meths[:12],
else:
# options = [{'label': x, 'value': x} for x in method_options]
value = meths[12:],
else:
if radio_value == 'Selected':
value = [['SVM', 'Ridge',
'Permutation (Ridge)',
'Shapley Value (Ridge)' ,
'Tree','XGB','RF',
'Permutation (RF)',
'Shapley Value (RF)' ,
'Epsilon-LRP (MLP)',
'Guided Backpropagation (MLP)',
'Permutation (MLP)',
'Shapley Value (MLP)']]
elif radio_value == 'All':
# options = [{'label': x, 'value': x} for x in method_options]
value = meths2,
elif radio_value == 'Model Specific':
# options = [{'label': x, 'value': x} for x in method_options]
value = meths2[:12],
else:
# options = [{'label': x, 'value': x} for x in method_options]
value = meths2[12:],
return value
## clustering select split or noise
@app.callback(Output('controls-container', 'style'), [Input('pert-select_clus', 'value')])
def toggle_container(toggle_value):
if toggle_value == 'Data Split':
return {'display': 'none'}
else:
return {'display': 'block'}
@app.callback(Output('controls-container_dr', 'style'), [Input('pert-select_dr', 'value')])
def toggle_container(toggle_value):
if toggle_value == 'Data Split':
return {'display': 'none'}
else:
return {'display': 'block'}
# ###### select figure
# @app.callback(
# Output("select_summary", "value"),
# Output("all_summary", "value"),
# Output("select_raw", "value"),
# Output("all_raw", "value"),
# Output("reset-button","n_clicks"),
# Output("submit-button","n_clicks"),
# Input("select_summary", "value"),
# Input("all_summary", "value"),
# Input("select_raw", "value"),
# Input("all_raw", "value"),
# Input("reset-button","n_clicks")
# )
# def update_summary_checklists(select_summary, all_summary,select_raw,all_raw,reset):
# if reset>0:
# return plot_summary_options,['All_summary' ],plot_raw_options,['All_raw' ],0,1
# else:
# new = list(sync_checklists(select_summary, all_summary,plot_summary_options,kind='summary')+sync_checklists(select_raw, all_raw,plot_raw_options,kind='raw'))+[0,1]
# # new.append(0)
# return new
######## make figures
# @app.callback(
# Output("title_summary", "children"),
# Output("subtitle_summary", "children"),
# Output("show_heatmap", "children"),
# Output("show_line", "children"),
# Output("show_heat2", "children"),
# Output("show_bump", "children"),
# Output("show_fit", "children"),
# # Output("show_dot", "children"),
# # Output("show_cor", "children"),
# [Input('url', 'pathname'),
# State("select_summary", "value"),
# Input('submit-button','n_clicks'),
# ],
# prevent_initial_call=False
# )
# def show(pathname,plot_selected,click):
# if click and click>0 and pathname!='/knn':
# options = ['heatmap','line','heat2','bump','fit']
# # options = ['heatmap','line','bump','fit','dot','cor']
# title = []
# subtitle = []
# if len(plot_selected)>0:
# title=html.H4("Summary Figures", style={"color": "slateblue",'text-align':'center','font-weight': 'bold'})
# subtitle=html.H5("Aggregated over all data sets", style={"color": "mediumslateblue",'text-align':'center'})
# return list([title]+[subtitle]+[display_figure(pp,plot_selected,click,pathname) for pp in options])
# raise PreventUpdate
@app.callback(
Output("title_summary", "children"),
Output("subtitle_summary", "children"),
Output("show_heatmap", "children"),
Output("show_line", "children"),
Output("show_heat2", "children"),
Output("show_bump", "children"),
Output("show_fit", "children"),
Output("title_summary_raw", "children"),
Output("show_line_raw", "children"),
Output("show_scatter_raw", "children"),
# Output("show_acc_raw", "children"),
Output("show_heatmap_raw", "children"),
[Input('url', 'pathname'),
Input("qq", "value"),
# Input('submit-button','n_clicks'),
],
prevent_initial_call=False
)
def show(pathname,qq):
# if click and click>0 and pathname!='/knn':
if pathname!='/knn':
options = ['heatmap','line', 'heat2','bump','fit']
options2 = ['line_raw','scatter_raw','heatmap_raw']
if qq=='Q1':
plot_selected = ['heat2','bump','line']
plot_selected2=['line_raw']
if qq=='Q2':
plot_selected = ['heatmap']
plot_selected2=['heatmap_raw']
if qq=='Q3':
plot_selected = ['fit']
plot_selected2=['scatter_raw']
title=html.H4("Summary Figures for "+qq, style={"color": "slateblue",'text-align':'center','font-weight': 'bold'})
subtitle=html.H5("Aggregated over all data sets", style={"color": "mediumslateblue",'text-align':'center'})
title2=html.H4("Detailed Figures for "+qq, style={"color": "slateblue",'text-align':'center'})
return list([title]+[subtitle]+[display_figure(pp,plot_selected,pathname) for pp in options]+[title2]+
[display_figure(pp,plot_selected2,pathname) for pp in options2] )
raise PreventUpdate
# @app.callback(
# Output("title_summary_raw", "children"),
# Output("show_line_raw", "children"),
# Output("show_scatter_raw", "children"),
# # Output("show_acc_raw", "children"),
# Output("show_heatmap_raw", "children"),
# [Input('url', 'pathname'),
# State("select_raw", "value"),
# Input('submit-button','n_clicks'),
# ],
# prevent_initial_call=True
# )
# def show_raw(pathname,plot_selected,click):
# if click and click>0 and pathname!='/knn':
# options = [,'scatter_raw',']
# title = []
# if len(plot_selected)>0:
# return list([title]+[display_figure(pp,plot_selected,click,pathname) for pp in options])
# raise PreventUpdate
@app.callback(
Output("title_summary_knn", "children"),
Output("subtitle_summary_knn", "children"),
Output("show_heat2_knn", "children"),
Output("show_bump_knn", "children"),
Output("show_line_knn", "children"),
Output("title_raw_knn", "children"),
Output("show_line_raw_knn", "children"),
Output("show_k_raw_knn", "children"),
[Input('url', 'pathname'),
],
prevent_initial_call=False
)
def show_knn(pathname):
# if click and click>0 and pathname!='/knn':
if pathname=='/knn':
options = ['heat2','bump','line']
options2 = ['line_raw','k_raw']
plot_selected = ['heat2','bump','line']
plot_selected2=['line_raw','k_raw']
title=html.H4("Summary Figures for Q1", style={"color": "slateblue",'text-align':'center','font-weight': 'bold'})
subtitle=html.H5("Aggregated over all data sets", style={"color": "mediumslateblue",'text-align':'center'})
title2=html.H4("Detailed Figures for Q1", style={"color": "slateblue",'text-align':'center'})
return list([title]+[subtitle]+[display_figure(pp,plot_selected,pathname) for pp in options]+[title2]+
[display_figure(pp,plot_selected2,pathname) for pp in options2] )
raise PreventUpdate
########################################
######## make figures for new data
########################################
@app.callback(Output('output-datatable', 'children'),
Input('upload-data', 'contents'),
State('upload-data', 'filename'),
State('upload-data', 'last_modified'),
State('url', 'pathname'))
def update_output(list_of_contents, list_of_names, list_of_dates,pathname):
if list_of_contents is not None:
children = [
parse_contents(c, n, d,pathname) for c, n, d in
zip(list_of_contents, list_of_names, list_of_dates)]
return children
raise PreventUpdate
@app.callback(
Output("new_options", "children"),
Input('upload-data', 'contents'),
prevent_initial_call=True
)
def update_options(contents):
if contents is not None:
children = html.Div([
html.P("Select NEW Summary Graphs you want to show"),
dcc.Checklist(id="all_summary_new",
options=[{"label": 'All', "value":'All_summary_new' }],value= []),
dcc.Checklist(id="select_summary_new",
options=[{"label": plot_summary_options[i], "value": i+'_new'} for i in list(plot_summary_options.keys())[1:4]],
value=[],
),
dbc.Button('Show New Figures', id='submit-button_new',n_clicks = 0, color="primary",className="me-1", size="sm"),
dbc.Button('Reset New Figures', id='reset-button_new',n_clicks=0, color="secondary",className="me-1", size="sm"),
html.Br(),
dbc.Button('Remove Data', id='remove-button_new',n_clicks=0, color="warning",className="me-1", size="sm"),
])
return children
elif len(contents)==0:
children = html.Div([
html.P("Data Removed")])
return children
raise PreventUpdate
@app.callback(
Output('upload-data', 'contents'),
State('upload-data', 'contents'),
Input('remove-button_new','n_clicks'),
prevent_initial_call=True
)
def remove_new(contents,remove):
if remove==0:
return contents
else:
return []
@app.callback(
Output("select_summary_new", "value"),
Output("all_summary_new", "value"),
Output("reset-button_new","n_clicks"),
Output("submit-button_new","n_clicks"),
Input("select_summary_new", "value"),
Input("all_summary_new", "value"),
Input("reset-button_new","n_clicks"),
)
def update_summary_checklists(select_summary, all_summary,reset):
if reset>0:
return [],[],0,1
else:
return list(sync_checklists(select_summary, all_summary,plot_summary_new_options,kind='summary_new'))+[0,0]
@app.callback(
Output("title_summary_new", "children"),
Output("show_line_new", "children"),
Output("show_heat2_new", "children"),
Output("show_bump_new", "children"),
# Output("show_fit_new", "children"),
[ Input('url', 'pathname'),
Input("select_summary_new", "value"),
],
prevent_initial_call=True
)
def show_new(pathname,plot_selected):
if pathname!='/knn':
options = ['line_new','heat2_new','bump_new']
title = []
if len(plot_selected)>0:
title=html.H4("Summary Figures with New Data", style={"color": "slateblue",'text-align':'center'})
return list([title]+[display_figure(pp,plot_selected,pathname) for pp in options])
raise PreventUpdate
# @app.callback(
# Output("title_summary_knn_new", "children"),
# Output("show_line_knn_new", "children"),
# # Output("show_heat2_knn_new", "children"),
# Output("show_bump_knn_new", "children"),
# [ State('url', 'pathname'),
# ],
# prevent_initial_call=True
# )
# def show_knn_new(pathname,plot_selected):
# if pathname=='/knn':
# options = ['line_new','bump_new']
# plot_selected=options
# title = []
# if len(plot_selected)>0:
# title=html.H4("Summary Figures with New Data", style={"color": "slateblue",'text-align':'center'})
# return list([title]+[display_figure(pp,plot_selected,pathname) for pp in options])
# raise PreventUpdate
@app.callback(
Output("bump", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_bump(pathname,data_sel, method_sel,
k_sel, criteria_sel
):
if pathname == '/feature_importance_classification':
fig=build_bump(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_bump_reg(data_sel, method_sel,
k_sel, criteria_sel)
return fig
@app.callback(
Output("heatmap", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_heatmap(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_heat_summary(data_sel,method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_heat_summary_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
@app.callback(
Output("heatmap_raw", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_heatmap_raw(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_heat_raw(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_heat_raw_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
# @app.callback(
# Output("acc_raw", "figure"),
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# ],
# )
# def update_acc_raw(pathname,data_sel):
# if pathname == '/feature_importance_classification':
# fig=build_acc_raw(data_sel)
# return fig
# if pathname == '/feature_importance_regression':
# fig=build_acc_raw_reg(data_sel)
# return fig
@app.callback(
Output("line", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_line(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_line(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_line_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
@app.callback(
Output("heat2", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_heat2(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_heat_consis(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_heat_consis_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
@app.callback(
Output("line_raw", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_line_raw(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_line_raw(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_line_raw_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
@app.callback(
[Output("fit1", "figure"),
Output("fit2", "figure"),
Output("pv1", "figure"),
Output("pv2", "figure"),
],
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_fit(pathname,data_sel,method_sel,
k_sel, criteria_sel
):
if pathname == '/feature_importance_classification':
fig1,fig2,pv1,pv2=build_fit(data_sel, method_sel,
k_sel, criteria_sel)
return fig1,fig2,pv1,pv2
if pathname == '/feature_importance_regression':
fig1,fig2,pv1,pv2=build_fit_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig1,fig2,pv1,pv2
raise PreventUpdate
# @app.callback(
# [Output("fit1_new", "figure"),
# Output("fit2_new", "figure"),
# ],
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# Input("method-select", "value"),
# Input("k-select", "value"),
# Input("criteria-select", "value"),
# Input('stored-data', 'data')
# ],
# )
# def update_fit2(pathname,data_sel, method_sel,
# k_sel, criteria_sel,data):
# if pathname == '/feature_importance_classification':
# fig1,fig2=build_fit(data_sel, method_sel,
# k_sel, criteria_sel,data)
# return fig1,fig2
# if pathname == '/feature_importance_regression':
# fig1,fig2=build_fit_reg(data_sel, method_sel,
# k_sel, criteria_sel,data)
# return fig1,fig2
# raise PreventUpdate
#########################
@app.callback(
Output("scatter_raw", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
],
)
def update_scatter_raw(pathname,data_sel,method_sel,
k_sel, criteria_sel
#,noise_sel,sigma_sel
):
if pathname == '/feature_importance_classification':
fig=build_scatter_raw(data_sel, method_sel,
k_sel, criteria_sel)
return fig
if pathname == '/feature_importance_regression':
fig=build_scatter_raw_reg(data_sel,method_sel,
k_sel, criteria_sel)
return fig
raise PreventUpdate
#####################################
@app.callback(
Output("line_new", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
Input('stored-data', 'data')
],
)
def update_line2(pathname,data_sel, method_sel,
k_sel, criteria_sel,data
):
if pathname == '/feature_importance_classification':
fig=build_line(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
if pathname == '/feature_importance_regression':
fig=build_line_reg(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
raise PreventUpdate
@app.callback(
Output("heat2_new", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
Input('stored-data', 'data')
],
)
def update_heat22(pathname,data_sel, method_sel,
k_sel, criteria_sel,data
):
if pathname == '/feature_importance_classification':
fig=build_heat_consis(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
if pathname == '/feature_importance_regression':
fig=build_heat_consis_reg(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
raise PreventUpdate
@app.callback(
Output("bump_new", "figure"),
[Input('url', 'pathname'),
Input("data-select", "value"),
Input("method-select", "value"),
Input("k-select", "value"),
Input("criteria-select", "value"),
Input('stored-data', 'data')
],
)
def update_bump2(pathname,data_sel, method_sel,
k_sel, criteria_sel,data
):
if pathname == '/feature_importance_classification':
fig=build_bump(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
if pathname == '/feature_importance_regression':
fig=build_bump_reg(data_sel, method_sel,
k_sel, criteria_sel,data)
return fig
# @app.callback(
# [Output("cor1", "figure"),
# Output("cor2", "figure"),
# ],
# # Output("cor", "figure"),
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# Input("method-select", "value"),
# Input("k-select", "value"),
# Input("criteria-select", "value"),
# ],
# )
# def update_cor(pathname,data_sel,method_sel,
# k_sel, criteria_sel
# ):
# if pathname == '/feature_importance_classification':
# fig1,fig2 =build_cor(data_sel, method_sel,
# k_sel, criteria_sel)
# return fig1,fig2
# if pathname == '/feature_importance_regression':
# fig1,fig2 =build_cor_reg(data_sel,method_sel,
# k_sel, criteria_sel)
# return fig1,fig2
# raise PreventUpdate
# @app.callback(
# [Output("cor1_new", "figure"),
# Output("cor2_new", "figure"),
# ],
# # Output("cor_new", "figure"),
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# Input("method-select", "value"),
# Input("k-select", "value"),
# Input("criteria-select", "value"),
# Input('stored-data', 'data')
# ],
# )
# def update_cor2(pathname,data_sel, method_sel,
# k_sel, criteria_sel,data
# ):
# if pathname == '/feature_importance_classification':
# fig1,fig2 =build_cor(data_sel, method_sel,
# k_sel, criteria_sel,data)
# return fig
# if pathname == '/feature_importance_regression':
# fig1,fig2 =build_cor_reg(data_sel, method_sel,
# k_sel, criteria_sel,data)
# return fig1,fig2
# raise PreventUpdate
# @app.callback(
# [Output("dot1", "figure"),
# Output("dot2", "figure"),
# ],
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# Input("method-select", "value"),
# Input("k-select", "value"),
# Input("criteria-select", "value"),
# ],
# )
# def update_dot(pathname,data_sel,method_sel,
# k_sel, criteria_sel
# ):
# if pathname == '/feature_importance_classification':
# fig1,fig2=build_dot(data_sel, method_sel,
# k_sel,
# criteria_sel)
# if pathname == '/feature_importance_regression':
# fig1,fig2=build_dot_reg(data_sel, method_sel,
# k_sel,
# criteria_sel
# )
# return fig1,fig2
# @app.callback(
# [Output("dot1_new", "figure"),
# Output("dot2_new", "figure"),
# ],
# [Input('url', 'pathname'),
# Input("data-select", "value"),
# Input("method-select", "value"),
# Input("k-select", "value"),
# Input("criteria-select", "value"),
# Input('stored-data', 'data')
# ],
# )
# def update_dot2(pathname,data_sel,method_sel,
# k_sel, criteria_sel,data
# ):
# if pathname == '/feature_importance_classification':
# fig1,fig2=build_dot(data_sel, method_sel,
# k_sel,
# criteria_sel,data
# )
# if pathname == '/feature_importance_regression':
# fig1,fig2=build_dot_reg(data_sel, method_sel,
# k_sel,
# criteria_sel,data
# )
# return fig1,fig2
######################################
######## clustering
###########################################
@app.callback(
Output("heatmap_clus", "figure"),
[
Input("data-select_clus", "value"),
Input("method-select_clus", "value"),
Input("criteria-select_clus", "value"),
Input("noise-select_clus", "value"),
Input("sigma-select_clus", "value"),
Input("pert-select_clus", "value"),
],
)
def update_heatmap_clus(data_sel_clus,method_sel_clus,
criteria_sel_clus,
noise_sel_clus,
sigma_sel_clus,pert
):
if pert != 'Noise Addition':
fig=build_heat_summary_clus(data_sel_clus,method_sel_clus,
criteria_sel_clus,
None,
None)
else:
fig=build_heat_summary_clus(data_sel_clus,method_sel_clus,
criteria_sel_clus,
noise_sel_clus,
sigma_sel_clus)
return fig
# @app.callback(
# Output("acc_clus", "figure"),
# [
# Input("data-select_clus", "value"),
# Input("method-select_clus", "value"),
# Input("criteria-select_clus", "value"),
# Input("noise-select_clus", "value"),
# Input("sigma-select_clus", "value"),
# Input("pert-select_clus", "value"),
# ],
# )
# def update_acc_bar_clus(data_sel_clus,method_sel_clus,
# criteria_sel_clus,
# noise_sel_clus,
# sigma_sel_clus,pert
# ):
# if pert != 'Noise Addition':
# fig=build_acc_bar_clus(data_sel_clus,method_sel_clus,
# criteria_sel_clus,
# None,
# None)
# else:
# fig=build_acc_bar_clus(data_sel_clus,method_sel_clus,
# criteria_sel_clus,
# noise_sel_clus,
# sigma_sel_clus)
# return fig
@app.callback(
Output("line_clus", "figure"),
[