Spaces:
Sleeping
Sleeping
Eachan Johnson
commited on
Commit
·
ec66d6b
1
Parent(s):
8963b5e
Add refresh buttons
Browse files
app.py
CHANGED
@@ -291,7 +291,9 @@ with gr.Blocks() as demo:
|
|
291 |
"""
|
292 |
# Finding the dynamic parameters
|
293 |
|
294 |
-
**Adjust the sliders** to
|
|
|
|
|
295 |
|
296 |
**Click "Fit parameters!"** to automatically find the best fitting parameters.
|
297 |
|
@@ -308,12 +310,14 @@ with gr.Blocks() as demo:
|
|
308 |
gr.Slider(label="Resistance-free half-life", info="Relative to start of clinical use",
|
309 |
value=30., minimum=0., maximum=50., scale=10),
|
310 |
]
|
|
|
311 |
fit_button = gr.Button("Fit parameters!", scale=6)
|
312 |
|
313 |
# with gr.Row():
|
314 |
fit_message = gr.Markdown(parameter_msg, inputs=param_sliders)
|
315 |
plot = gr.Plot(lambda *x: plot_data_altair(df=data, params=x), inputs=param_sliders, format="png", label="Model fit", scale=4)
|
316 |
|
|
|
317 |
fit_button.click(lambda *x: fit_to_data(data, init_params=x), inputs=param_sliders, outputs=param_sliders)
|
318 |
|
319 |
with gr.Tab("Forecasting the future!"):
|
@@ -321,7 +325,9 @@ with gr.Blocks() as demo:
|
|
321 |
"""
|
322 |
# Forecasting future discovery and resistance!
|
323 |
|
324 |
-
**Adjust the sliders** to see how changes these parameters would change the future.
|
|
|
|
|
325 |
|
326 |
**Click "Fit parameters!"** on the previous tab to set the parameters to fit historical data,
|
327 |
then come back to this tab to check the forecast.
|
@@ -331,13 +337,19 @@ with gr.Blocks() as demo:
|
|
331 |
|
332 |
with gr.Row():
|
333 |
forecast_sliders = [
|
334 |
-
gr.Slider(label="⨉ pool size", info="Increase in accessible antibiotic classes",
|
335 |
-
|
336 |
-
gr.Slider(label="⨉
|
337 |
-
|
|
|
|
|
|
|
|
|
338 |
]
|
|
|
339 |
|
340 |
fit_message = gr.Markdown(forecast_msg, inputs=param_sliders + forecast_sliders)
|
341 |
forecast = gr.Plot(lambda *x: plot_data_forecast_altair(df=data, params=x), inputs=param_sliders + forecast_sliders, format="png", label="Forecast", scale=4)
|
|
|
342 |
|
343 |
-
demo.launch(
|
|
|
291 |
"""
|
292 |
# Finding the dynamic parameters
|
293 |
|
294 |
+
**Adjust the sliders** to alter the parameters underlying the rate of antibiotic discovery and resistance.
|
295 |
+
|
296 |
+
**Click update plot** to see what the dynamics would look like with your parameters.
|
297 |
|
298 |
**Click "Fit parameters!"** to automatically find the best fitting parameters.
|
299 |
|
|
|
310 |
gr.Slider(label="Resistance-free half-life", info="Relative to start of clinical use",
|
311 |
value=30., minimum=0., maximum=50., scale=10),
|
312 |
]
|
313 |
+
refresh_button = gr.Button("Update plot", scale=6)
|
314 |
fit_button = gr.Button("Fit parameters!", scale=6)
|
315 |
|
316 |
# with gr.Row():
|
317 |
fit_message = gr.Markdown(parameter_msg, inputs=param_sliders)
|
318 |
plot = gr.Plot(lambda *x: plot_data_altair(df=data, params=x), inputs=param_sliders, format="png", label="Model fit", scale=4)
|
319 |
|
320 |
+
refresh_button.click(lambda *x: plot_data_altair(df=data, params=x), inputs=param_sliders, outputs=plot)
|
321 |
fit_button.click(lambda *x: fit_to_data(data, init_params=x), inputs=param_sliders, outputs=param_sliders)
|
322 |
|
323 |
with gr.Tab("Forecasting the future!"):
|
|
|
325 |
"""
|
326 |
# Forecasting future discovery and resistance!
|
327 |
|
328 |
+
**Adjust the sliders** to see how changes in these parameters would change the future.
|
329 |
+
|
330 |
+
**Click update plot** to see what the dynamics would look like with your parameters.
|
331 |
|
332 |
**Click "Fit parameters!"** on the previous tab to set the parameters to fit historical data,
|
333 |
then come back to this tab to check the forecast.
|
|
|
337 |
|
338 |
with gr.Row():
|
339 |
forecast_sliders = [
|
340 |
+
gr.Slider(label="⨉ pool size", info="Increase in accessible antibiotic classes",
|
341 |
+
value=1., minimum=0., maximum=10., step=.2, scale=10),
|
342 |
+
gr.Slider(label="⨉ discovery rate", info="Increase in rate of discovery",
|
343 |
+
value=1., minimum=0., maximum=10., step=.2, scale=10),
|
344 |
+
gr.Slider(label="⨉ half-life", info="Increase in resistance-free half-life",
|
345 |
+
value=1., minimum=0., maximum=10., step=.2, scale=10),
|
346 |
+
gr.Slider(label="🔮", info="In years",
|
347 |
+
value=100., minimum=0., maximum=200., step=.5, scale=10),
|
348 |
]
|
349 |
+
refresh_button_forecast = gr.Button("Update plot", scale=6)
|
350 |
|
351 |
fit_message = gr.Markdown(forecast_msg, inputs=param_sliders + forecast_sliders)
|
352 |
forecast = gr.Plot(lambda *x: plot_data_forecast_altair(df=data, params=x), inputs=param_sliders + forecast_sliders, format="png", label="Forecast", scale=4)
|
353 |
+
refresh_button_forecast.click(lambda *x: plot_data_forecast_altair(df=data, params=x), inputs=param_sliders + forecast_sliders, outputs=forecast)
|
354 |
|
355 |
+
demo.launch()
|