Spaces:
Runtime error
Runtime error
masa729406
commited on
Commit
·
763a979
1
Parent(s):
cb7c9d8
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,34 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
|
5 |
+
from prophet import Prophet
|
6 |
+
|
7 |
+
|
8 |
+
def plot_forecast(example_name, period):
|
9 |
+
df = pd.read_csv(f'https://raw.githubusercontent.com/facebook/prophet/main/examples/example_{example_name}.csv')
|
10 |
+
df.columns = ['ds','y']
|
11 |
+
|
12 |
+
m = Prophet()
|
13 |
+
m.fit(df)
|
14 |
+
future = m.make_future_dataframe(periods=period)
|
15 |
+
forecast = m.predict(future)
|
16 |
+
fig = m.plot(forecast)
|
17 |
+
return fig
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
gr.Markdown(
|
21 |
+
"""
|
22 |
+
時系列予測モデルの結果
|
23 |
+
""")
|
24 |
+
with gr.Row():
|
25 |
+
example = gr.Dropdown(["air_passengers", "pedestrians_covid", "retail_sales"], label="データソース", value="air_passengers")
|
26 |
+
period = gr.Slider(25, 250, 25, step=25, label="予測期間")
|
27 |
+
|
28 |
+
plt = gr.Plot()
|
29 |
+
|
30 |
+
example.change(plot_forecast, [example,period], plt, queue=False)
|
31 |
+
period.change(plot_forecast, [example,period], plt, queue=False)
|
32 |
+
demo.load(plot_forecast, [example,period], plt, queue=False)
|
33 |
+
|
34 |
demo.launch()
|