masa729406 commited on
Commit
763a979
·
1 Parent(s): cb7c9d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -19
app.py CHANGED
@@ -1,21 +1,34 @@
1
  import gradio as gr
2
- # resuests モジュールをインポート
3
- import requests
4
- from bs4 import BeautifulSoup
5
-
6
- # Webページを取得して解析する
7
- load_url = "https://www.football-lab.jp/kyot/match/"
8
- html = requests.get(load_url)
9
- soup = BeautifulSoup(html.content, "html.parser")
10
-
11
- def prediction_audience(イワシの値段):
12
- return イワシの値段 * 1000
13
-
14
- demo = gr.Interface(
15
- fn=prediction_audience,
16
- inputs=["number"],
17
- outputs="number",
18
- title="イワシの値段による「サンガスタジアム by KYOCERA」の観客動員予測",
19
- description="「サンガスタジアム by KYOCERA」で行われる京都サンガFCのJ1リーグの直近の試合の観客動員数をイワシの値段から予測する。",
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()