modified 2
Browse files- app.py +17 -20
- requiremets.txt +1 -2
app.py
CHANGED
@@ -1,31 +1,28 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import pandas as pd
|
3 |
-
from sklearn.linear_model import LinearRegression
|
4 |
-
import numpy as np
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
model = LinearRegression()
|
14 |
-
data['date_ordinal'] = pd.to_datetime(data['date']).map(pd.Timestamp.toordinal)
|
15 |
-
X = data['date_ordinal'].values.reshape(-1, 1)
|
16 |
-
y = data['sales'].values
|
17 |
-
model.fit(X, y)
|
18 |
|
19 |
-
def
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
# Gradioインターフェースの定義
|
25 |
iface = gr.Interface(
|
26 |
-
fn=
|
27 |
-
inputs=
|
28 |
-
outputs=gr.components.
|
29 |
)
|
30 |
|
31 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
import pandas as pd
|
|
|
|
|
4 |
|
5 |
+
# サンプルデータ
|
6 |
+
data = {
|
7 |
+
'年月': ['2023-01', '2023-02', '2023-03', '2023-04', '2023-05', '2023-06'],
|
8 |
+
'乗客数': [1200, 1500, 1700, 1600, 1800, 2000]
|
9 |
+
}
|
10 |
|
11 |
+
df = pd.DataFrame(data)
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
def plot_passenger_trends():
|
14 |
+
fig, ax = plt.subplots()
|
15 |
+
ax.plot(df['年月'], df['乗客数'], marker='o')
|
16 |
+
ax.set_title('JRの乗客数の推移')
|
17 |
+
ax.set_xlabel('年月')
|
18 |
+
ax.set_ylabel('乗客数 (千人)')
|
19 |
+
return fig
|
20 |
|
21 |
# Gradioインターフェースの定義
|
22 |
iface = gr.Interface(
|
23 |
+
fn=plot_passenger_trends,
|
24 |
+
inputs=[],
|
25 |
+
outputs=gr.components.Plot(label="JRの乗客数の推移")
|
26 |
)
|
27 |
|
28 |
if __name__ == "__main__":
|
requiremets.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
gradio
|
|
|
2 |
pandas
|
3 |
-
scikit-learn
|
4 |
-
numpy
|
5 |
|
|
|
1 |
gradio
|
2 |
+
matplotlib
|
3 |
pandas
|
|
|
|
|
4 |
|