aliabd commited on
Commit
b48e2e6
·
1 Parent(s): 51d3b6b

Upload with huggingface_hub

Browse files
Files changed (5) hide show
  1. DESCRIPTION.md +1 -0
  2. README.md +6 -7
  3. __pycache__/run.cpython-36.pyc +0 -0
  4. requirements.txt +4 -0
  5. run.py +69 -0
DESCRIPTION.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Generate a plot based on 5 inputs.
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Outbreak Forecast Main
3
- emoji: 📊
4
- colorFrom: yellow
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: outbreak_forecast_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
__pycache__/run.cpython-36.pyc ADDED
Binary file (1.29 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy
2
+ matplotlib
3
+ bokeh
4
+ plotlyhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from math import sqrt
3
+ import matplotlib
4
+
5
+ matplotlib.use("Agg")
6
+
7
+ import matplotlib.pyplot as plt
8
+ import numpy as np
9
+ import plotly.express as px
10
+ import pandas as pd
11
+
12
+
13
+ def outbreak(plot_type, r, month, countries, social_distancing):
14
+ months = ["January", "February", "March", "April", "May"]
15
+ m = months.index(month)
16
+ start_day = 30 * m
17
+ final_day = 30 * (m + 1)
18
+ x = np.arange(start_day, final_day + 1)
19
+ pop_count = {"USA": 350, "Canada": 40, "Mexico": 300, "UK": 120}
20
+ if social_distancing:
21
+ r = sqrt(r)
22
+ df = pd.DataFrame({"day": x})
23
+ for country in countries:
24
+ df[country] = x ** (r) * (pop_count[country] + 1)
25
+
26
+ if plot_type == "Matplotlib":
27
+ fig = plt.figure()
28
+ plt.plot(df["day"], df[countries].to_numpy())
29
+ plt.title("Outbreak in " + month)
30
+ plt.ylabel("Cases")
31
+ plt.xlabel("Days since Day 0")
32
+ plt.legend(countries)
33
+ return fig
34
+ elif plot_type == "Plotly":
35
+ fig = px.line(df, x="day", y=countries)
36
+ fig.update_layout(
37
+ title="Outbreak in " + month,
38
+ xaxis_title="Cases",
39
+ yaxis_title="Days Since Day 0",
40
+ )
41
+ return fig
42
+ else:
43
+ raise ValueError("A plot type must be selected")
44
+
45
+
46
+ inputs = [
47
+ gr.Dropdown(["Matplotlib", "Plotly"], label="Plot Type"),
48
+ gr.Slider(1, 4, 3.2, label="R"),
49
+ gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
50
+ gr.CheckboxGroup(
51
+ ["USA", "Canada", "Mexico", "UK"], label="Countries", value=["USA", "Canada"]
52
+ ),
53
+ gr.Checkbox(label="Social Distancing?"),
54
+ ]
55
+ outputs = gr.Plot()
56
+
57
+ demo = gr.Interface(
58
+ fn=outbreak,
59
+ inputs=inputs,
60
+ outputs=outputs,
61
+ examples=[
62
+ ["Matplotlib", 2, "March", ["Mexico", "UK"], True],
63
+ ["Plotly", 3.6, "February", ["Canada", "Mexico", "UK"], False],
64
+ ],
65
+ cache_examples=True,
66
+ )
67
+
68
+ if __name__ == "__main__":
69
+ demo.launch()