-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_ins.py
318 lines (225 loc) · 12.7 KB
/
app_ins.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
### Data
import pandas as pd
import pickle
### Graphing
import plotly.graph_objects as go
### Dash
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Output, Input
# from dash import Dash, dcc
## Navbar
from nav import Navbar
import numpy as np
import plotly.express as px
from dash import dash_table
from PIL import Image
nav = Navbar()
section = dcc.Markdown(
'''
# Instruction
### Dashboard
We have interactive results of five sections:
* Feature importance (Classification),
* Feature importance (Regression),
* Clustering,
* Dimension reduction (Clustering),
* Dimension reduction (Local Neighbors)
Each section has the same layout, with options on the left and summary and raw plots on the right.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
option = dcc.Markdown(
'''
### Options
* Users can select IML questions to address
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
up = dcc.Markdown(
'''
* Users can upload their own data set, which has to satisfy the format requirement.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
pert = dcc.Markdown(
'''
* Perturbation selection: select data splitting or noise addition in clustering task.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
data = dcc.Markdown(
'''
* Data selection: we have results of all the data sets we used in this empirical study. User can show the results of selected data.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
meth =dcc.Markdown(
'''
* Method selection: show the results of selected methods.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
criteria =dcc.Markdown(
'''
* Select criteria: figures are generated with the selected criteria.
* Three options in Feature Importance section: RBO, Jaccard and Kendall's Tau.
* Four options in Clustering Importance section: ARI, Mutual Information (MI), fowlkes mallows, and V measuer(v_measure)
* Four options in Dimension Reduction+Clustering section: ARI, Mutual Information (MI), fowlkes mallows, and V measuer(v_measure)
* One options in Dimension Reduction+Local Neighbor section: Jaccard similarity.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
noise=dcc.Markdown(
'''
* Select Noise Level (sigma): control the level of noise addition, where the added noise has variance sigma.
* Select Noise Type: normal or laplace noise.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
other=dcc.Markdown(
'''
* Section Specific options:
* Select Top K in Feature Importance section: select the number of most important features we want to compare.
* Select Rank in Dimension Reduction: select the rank of reduced dimension we aim to evaluate with.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
### Figures
heat = dcc.Markdown(
'''
#### Q2 Summary figures:
* Cross-method consistency heatmap: the cross-method average consistency of interpretations obtain from each pair of IML methods, averaged over 100 repeats and different data sets.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
line = dcc.Markdown(
'''
#### Q1 Summary Figures
* Within-method consistency heatmap: the average within-method consistency of interpretations of an IML method aggregated over 100 repeats. The x-axis is the data sets we used, ordered by # feature/# observation ratio, and the y-axis is the consistency score of this task, ranging in \[0,1\].
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
bump = dcc.Markdown(
'''
* Consistency bump plot: ranks IML methods by their consistency in each data set. The methods of the y-axis on the right is ordered by the average consistency across all data sets.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
# fit = dcc.Markdown(
# '''
# * Fit: to evaluate the relationship between prediction accuracy and interpretation consistency. The scatterplot shows the consistency score vs. predictive accuracy, with colors representing different IML methods. The points with the same color represent data sets, averaged over 100 repeats. The fitted regression lines between consistency score and predictive accuracy does not necessarily have positive coefficients.
# ''',
# mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
# cor = dcc.Markdown(
# '''
# * Cor: to evaluate the relationship between prediction accuracy and interpretation consistency. The histogram plots the correlation between consistency score and predictive accuracy for each method, average over different data sets and 100 repeats.
# ''',
# mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
dot = dcc.Markdown(
'''
#### Q3 Summary Figures
* Interpretation consistency, prediction consistency \& accuracy scatterplots: the figures investigte the relationships between prediction consistency and interpretation consistency, as well as the relationship between prediction consistency and prediction accuracy, either aggregated over each data set or aggregated over each IML method. In each scatter plot, fitted regression lines over one data or one method are plotted.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
pv = dcc.Markdown(
'''
* p-value table of fitted regression lines in the interpretation consistency, prediction consistency \& accuracy scatterplots.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
heat_raw = dcc.Markdown(
'''
#### Q2 Raw Figures:
* Raw cross-methods consistency heatmap: the cross-method average consistency of interpretations in each data set, along with prediction accuracy.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
scatter = dcc.Markdown(
'''
#### Q3 Raw Figures:
* Raw consistency \& accuracy scatterplots: the consistency score against prediction accuracy for each data set, where scatters represent different IML methods.
''',
mathjax=True, dangerously_allow_html=True, style={'marginLeft': '5%', 'width': '90%'})
line_raw = dcc.Markdown(
'''
#### Q1 Raw Figures:
* Raw consistency line plot: the interpretation consistency against some related parameter values of each data set.
* Featue Importance Section: Line plot of interpretation consistency scores of each data versus number of importance featuers, colored by IML methods.
* Clustering & Dimension Reduction (Clustering) sections: Line plot of interpretation consistency scores of each data versus noise level, colored by IML methods.
* Dimension Reduction (Local Neighbors): Line plot of interpretation consistency scores of each data versus number of neighbors, colored by IML methods.
''',
mathjax=True, style={'marginLeft': '5%', 'width': '80%'},
)
# Add images
import base64
bar = 'fig/bar.png' # replace with your own image
bar_image = base64.b64encode(open(bar, 'rb').read())
sel = 'fig/sel.png' # replace with your own image
sel_image = base64.b64encode(open(sel, 'rb').read())
upp = 'fig/up.png' # replace with your own image
up_image = base64.b64encode(open(upp, 'rb').read())
dat = 'fig/dat.png' # replace with your own image
data_image = base64.b64encode(open(dat, 'rb').read())
methh = 'fig/meth.png' # replace with your own image
meth_image = base64.b64encode(open(methh, 'rb').read())
crii = 'fig/cri.png' # replace with your own image
cri_image = base64.b64encode(open(crii, 'rb').read())
noisee = 'fig/noise.png' # replace with your own image
noise_image = base64.b64encode(open(noisee, 'rb').read())
heat_sum = 'fig/class_heat.png' # replace with your own image
heat_sum_image = base64.b64encode(open(heat_sum, 'rb').read())
heat_raww = 'fig/class_heat_raw.png' # replace with your own image
heat_raw_image = base64.b64encode(open(heat_raww, 'rb').read())
line_sum = 'fig/class_heat2.png' # replace with your own image
line_sum_image = base64.b64encode(open(line_sum, 'rb').read())
line_raww = 'fig/class_line_raw.png' # replace with your own image
line_raw_image = base64.b64encode(open(line_raww, 'rb').read())
scatterr = 'fig/class_scatter_raw.png' # replace with your own image
scatter_image = base64.b64encode(open(scatterr, 'rb').read())
dot_sum1 = 'fig/class_fit1.png' # replace with your own image
dot_sum1_image = base64.b64encode(open(dot_sum1, 'rb').read())
dot_sum2 = 'fig/class_fit2.png' # replace with your own image
dot_sum2_image = base64.b64encode(open(dot_sum2, 'rb').read())
pv1 = 'fig/class_pv1.png' # replace with your own image
pv1_image = base64.b64encode(open(pv1, 'rb').read())
pv2 = 'fig/class_pv2.png' # replace with your own image
pv2_image = base64.b64encode(open(pv2, 'rb').read())
bump_sum = 'fig/class_bump.png' # replace with your own image
bump_sum_image = base64.b64encode(open(bump_sum, 'rb').read())
aucc = 'fig/auc.png' # replace with your own image
aucc_image = base64.b64encode(open(aucc, 'rb').read())
auc_raw = 'fig/auc_raw.png' # replace with your own image
auc_raw_image = base64.b64encode(open(auc_raw, 'rb').read())
pertt = 'fig/pert.png' # replace with your own image
pert_image = base64.b64encode(open(pertt, 'rb').read())
def App_ins():
layout = html.Div([
nav,
section,
html.Img(src='data:image/png;base64,{}'.format(bar_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "80px"}),
option,
html.Img(src='data:image/png;base64,{}'.format(sel_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
up,
html.Img(src='data:image/png;base64,{}'.format(up_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
data,
html.Img(src='data:image/png;base64,{}'.format(data_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
meth,
html.Img(src='data:image/png;base64,{}'.format(meth_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
pert,
html.Img(src='data:image/png;base64,{}'.format(pert_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
criteria,
html.Img(src='data:image/png;base64,{}'.format(cri_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
noise,
html.Img(src='data:image/png;base64,{}'.format(noise_image.decode()),style={'text-align': 'center','width': '200px',"margin-left": "80px"}),
other,
## summary figures
line,
html.Img(src='data:image/png;base64,{}'.format(line_sum_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
bump,
html.Img(src='data:image/png;base64,{}'.format(bump_sum_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
line_raw,
html.Img(src='data:image/png;base64,{}'.format(line_raw_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
heat,
html.Img(src='data:image/png;base64,{}'.format(heat_sum_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
heat_raw,
html.Img(src='data:image/png;base64,{}'.format(heat_raw_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
dot,
html.Img(src='data:image/png;base64,{}'.format(dot_sum1_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
html.Img(src='data:image/png;base64,{}'.format(dot_sum2_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
pv,
html.Img(src='data:image/png;base64,{}'.format(pv1_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
html.Img(src='data:image/png;base64,{}'.format(pv2_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
## raw figures
scatter,
html.Img(src='data:image/png;base64,{}'.format(scatter_image.decode()),style={'text-align': 'center','width': '500px',"margin-left": "200px"}),
])
return layout