Spaces:
Sleeping
Sleeping
paragon-analytics
commited on
Commit
·
1c0f660
1
Parent(s):
579be1d
Update app.py
Browse files
app.py
CHANGED
@@ -86,10 +86,22 @@ def adr_predict(x):
|
|
86 |
# scores = list(zip(shap_values.data[0], shap_values.values[0, :, 1]))
|
87 |
# # plot the first sentence's explanation
|
88 |
# # plt = shap.plots.text(shap_values[0],display=False)
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
|
92 |
-
return {"Severe Reaction": float(scores.numpy()[1]), "Non-severe Reaction": float(scores.numpy()[0])},
|
|
|
93 |
# , word_attributions ,scores
|
94 |
|
95 |
def main(prob1):
|
@@ -119,7 +131,8 @@ with gr.Blocks(title=title) as demo:
|
|
119 |
# "--": "darkblue",
|
120 |
# "-": "blue", "NA":"white"})
|
121 |
|
122 |
-
interpretation = gr.components.Interpretation(prob1)
|
|
|
123 |
|
124 |
|
125 |
submit_btn.click(
|
@@ -127,12 +140,12 @@ with gr.Blocks(title=title) as demo:
|
|
127 |
[prob1],
|
128 |
[label
|
129 |
# ,intp
|
130 |
-
,
|
131 |
], api_name="adr"
|
132 |
)
|
133 |
|
134 |
gr.Markdown("### Click on any of the examples below to see to what extent they contain resilience messaging:")
|
135 |
-
gr.Examples([["I have minor pain."],["I have severe pain."]], [prob1], [label,
|
136 |
], main, cache_examples=True)
|
137 |
|
138 |
demo.launch()
|
|
|
86 |
# scores = list(zip(shap_values.data[0], shap_values.values[0, :, 1]))
|
87 |
# # plot the first sentence's explanation
|
88 |
# # plt = shap.plots.text(shap_values[0],display=False)
|
89 |
+
|
90 |
+
# shap_scores = interpretation_function(str(x).lower())
|
91 |
+
|
92 |
+
shap_values = explainer(str(x).lower(), fixed_context=1)
|
93 |
+
plot = shap.plots.text(shap_values[0], max_display=6,
|
94 |
+
order=shap.Explanation.abs, show_data='auto', show=False)
|
95 |
+
|
96 |
+
plt.tight_layout()
|
97 |
+
local_plot = plt.gcf()
|
98 |
+
plt.rcParams['figure.figsize'] = 6,4
|
99 |
+
plt.close()
|
100 |
+
|
101 |
|
102 |
|
103 |
+
return {"Severe Reaction": float(scores.numpy()[1]), "Non-severe Reaction": float(scores.numpy()[0])}, local_plot
|
104 |
+
# shap_scores
|
105 |
# , word_attributions ,scores
|
106 |
|
107 |
def main(prob1):
|
|
|
131 |
# "--": "darkblue",
|
132 |
# "-": "blue", "NA":"white"})
|
133 |
|
134 |
+
# interpretation = gr.components.Interpretation(prob1)
|
135 |
+
local_plot = gr.Plot(label = 'Shap:')
|
136 |
|
137 |
|
138 |
submit_btn.click(
|
|
|
140 |
[prob1],
|
141 |
[label
|
142 |
# ,intp
|
143 |
+
,local_plot
|
144 |
], api_name="adr"
|
145 |
)
|
146 |
|
147 |
gr.Markdown("### Click on any of the examples below to see to what extent they contain resilience messaging:")
|
148 |
+
gr.Examples([["I have minor pain."],["I have severe pain."]], [prob1], [label,local_plot
|
149 |
], main, cache_examples=True)
|
150 |
|
151 |
demo.launch()
|