Spaces:
Runtime error
Runtime error
zhang qiao
commited on
Commit
·
ce6a6f8
1
Parent(s):
8cf4695
Upload folder using huggingface_hub
Browse files- __pycache__/demo.cpython-310.pyc +0 -0
- best_models.csv +7 -7
- demo.py +2 -2
- demo2 +275 -0
- gr_app/GradioApp.py +1 -1
- gr_app/__pycache__/GradioApp.cpython-310.pyc +0 -0
__pycache__/demo.cpython-310.pyc
CHANGED
Binary files a/__pycache__/demo.cpython-310.pyc and b/__pycache__/demo.cpython-310.pyc differ
|
|
best_models.csv
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
sku,best_model,characteristic
|
2 |
-
Item_A
|
3 |
-
Item_B
|
4 |
-
Item_C
|
5 |
-
Item_D
|
6 |
-
Item_E
|
7 |
-
Item_F
|
|
|
1 |
+
sku,best_model,characteristic,predictability,RMSE,Intermittent Scores
|
2 |
+
Item_A,,,,,
|
3 |
+
Item_B,,,,,
|
4 |
+
Item_C,,,,,
|
5 |
+
Item_D,,,,,
|
6 |
+
Item_E,,,,,
|
7 |
+
Item_F,,,,,
|
demo.py
CHANGED
@@ -41,7 +41,7 @@ with demo:
|
|
41 |
|
42 |
md_ts_data_info = gr.Markdown()
|
43 |
|
44 |
-
df_ts_data = gr.
|
45 |
|
46 |
with gr.Accordion('Input Data Visualisation', open=False):
|
47 |
dropdown_ts_data = gr.Dropdown(**args.dropdown_ts_data)
|
@@ -68,7 +68,7 @@ with demo:
|
|
68 |
gr.Markdown('Upload previous model selection result (if have):')
|
69 |
file_upload_model_data = gr.File(**args.file_upload_model_data)
|
70 |
|
71 |
-
df_model_data = gr.
|
72 |
file_model_data = gr.File()
|
73 |
|
74 |
accordion_model_selection = gr.Accordion(
|
|
|
41 |
|
42 |
md_ts_data_info = gr.Markdown()
|
43 |
|
44 |
+
df_ts_data = gr.Dataframe(**args.df_ts_data)
|
45 |
|
46 |
with gr.Accordion('Input Data Visualisation', open=False):
|
47 |
dropdown_ts_data = gr.Dropdown(**args.dropdown_ts_data)
|
|
|
68 |
gr.Markdown('Upload previous model selection result (if have):')
|
69 |
file_upload_model_data = gr.File(**args.file_upload_model_data)
|
70 |
|
71 |
+
df_model_data = gr.Dataframe()
|
72 |
file_model_data = gr.File()
|
73 |
|
74 |
accordion_model_selection = gr.Accordion(
|
demo2
ADDED
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from gr_app2 import args, GradioApp
|
5 |
+
|
6 |
+
demo = gr.Blocks(**args.block)
|
7 |
+
|
8 |
+
with demo:
|
9 |
+
app = GradioApp()
|
10 |
+
|
11 |
+
md__title = gr.Markdown(**args.md__title)
|
12 |
+
|
13 |
+
with gr.Row():
|
14 |
+
with gr.Column():
|
15 |
+
file__historical = gr.File(**args.file__historical)
|
16 |
+
|
17 |
+
with gr.Column():
|
18 |
+
file__future = gr.File(**args.file__future)
|
19 |
+
md__future = gr.Markdown(**args.md__future)
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
btn__load_historical_demo = gr.Button("Load Demo Historical Data")
|
23 |
+
btn__load_future_demo = gr.Button("Load Demo Future Data")
|
24 |
+
|
25 |
+
with gr.Row():
|
26 |
+
number__n_predict = gr.Number(
|
27 |
+
value=app.n_predict,
|
28 |
+
**args.number__n_predict)
|
29 |
+
|
30 |
+
number__window_length = gr.Number(
|
31 |
+
value=app.window_length,
|
32 |
+
**args.number__window_length
|
33 |
+
)
|
34 |
+
|
35 |
+
textbox__target_column = gr.Textbox(
|
36 |
+
value=app.target_column,
|
37 |
+
**args.textbox__target_column
|
38 |
+
)
|
39 |
+
|
40 |
+
number__n_predict.change(
|
41 |
+
app.number__n_predict__change,
|
42 |
+
[number__n_predict]
|
43 |
+
)
|
44 |
+
|
45 |
+
number__window_length.change(
|
46 |
+
app.number__window_length__change,
|
47 |
+
[number__window_length]
|
48 |
+
)
|
49 |
+
|
50 |
+
textbox__target_column.change(
|
51 |
+
app.textbox__target_column__change,
|
52 |
+
[textbox__target_column]
|
53 |
+
)
|
54 |
+
|
55 |
+
# ---------- #
|
56 |
+
# Data Views #
|
57 |
+
# ---------- #
|
58 |
+
|
59 |
+
with gr.Tabs():
|
60 |
+
with gr.Tab('Table View'):
|
61 |
+
df__table_view = gr.Dataframe(**args.df__table_view)
|
62 |
+
|
63 |
+
with gr.Tab('Chart View'):
|
64 |
+
dropdown__chart_view_filter = gr.Dropdown(
|
65 |
+
multiselect=True,
|
66 |
+
label='Filter')
|
67 |
+
plot__chart_view = gr.Plot()
|
68 |
+
|
69 |
+
with gr.Tab('Seasonality and Auto Correlation'):
|
70 |
+
dropdown__seasonality_decompose = gr.Dropdown(
|
71 |
+
label='Please select column to decompose')
|
72 |
+
|
73 |
+
with gr.Row():
|
74 |
+
plot__seasonality_decompose = gr.Plot()
|
75 |
+
plot_acg_pacf = gr.Plot()
|
76 |
+
|
77 |
+
with gr.Tab('Correlations'):
|
78 |
+
btn__plot_correlation = gr.Button('Plot Correlations')
|
79 |
+
plot__correlation = gr.Plot()
|
80 |
+
|
81 |
+
btn__plot_correlation.click(
|
82 |
+
app.btn__plot_correlation__click,
|
83 |
+
[],
|
84 |
+
[plot__correlation]
|
85 |
+
)
|
86 |
+
|
87 |
+
with gr.Tab("Data Profile"):
|
88 |
+
btn__profiling = gr.Button('Profile Data')
|
89 |
+
md__profiling = gr.Markdown()
|
90 |
+
plot__change_points = gr.Plot()
|
91 |
+
|
92 |
+
dropdown__seasonality_decompose.change(
|
93 |
+
app.dropdown__seasonality_decompose__change,
|
94 |
+
[dropdown__seasonality_decompose],
|
95 |
+
[plot__seasonality_decompose,
|
96 |
+
plot_acg_pacf]
|
97 |
+
)
|
98 |
+
|
99 |
+
btn__profiling.click(
|
100 |
+
app.btn__profiling__click,
|
101 |
+
[],
|
102 |
+
[md__profiling,
|
103 |
+
plot__change_points]
|
104 |
+
)
|
105 |
+
|
106 |
+
# ---------------------- #
|
107 |
+
# Fit data to forecaster #
|
108 |
+
# ---------------------- #
|
109 |
+
|
110 |
+
btn__fit_data = gr.Button(**args.btn__fit_data)
|
111 |
+
|
112 |
+
# =========== #
|
113 |
+
# Forecasting #
|
114 |
+
# =========== #
|
115 |
+
|
116 |
+
column__models = gr.Column(visible=True)
|
117 |
+
|
118 |
+
with column__models:
|
119 |
+
md__fit_ready = gr.Markdown(**args.md__fit_ready)
|
120 |
+
|
121 |
+
md__forecast_data_info = gr.Markdown()
|
122 |
+
|
123 |
+
# ------------- #
|
124 |
+
# Model Configs #
|
125 |
+
# ------------- #
|
126 |
+
|
127 |
+
with gr.Row():
|
128 |
+
checkbox__round_results = gr.Checkbox(
|
129 |
+
app.round_results,
|
130 |
+
label='Round Results',
|
131 |
+
interactive=True)
|
132 |
+
|
133 |
+
checkbox__round_results.change(
|
134 |
+
app.checkbox__round_results__change,
|
135 |
+
[checkbox__round_results],
|
136 |
+
[]
|
137 |
+
)
|
138 |
+
|
139 |
+
gr.Markdown('## Models')
|
140 |
+
# ------- #
|
141 |
+
# XGBoost #
|
142 |
+
# ------- #
|
143 |
+
with gr.Tab('XGBoost'):
|
144 |
+
|
145 |
+
with gr.Row():
|
146 |
+
checkbox__xgboost_cv = gr.Checkbox(
|
147 |
+
app.xgboost_cv, label='Cross Validation')
|
148 |
+
checkbox__xgboost_round = gr.Checkbox(
|
149 |
+
app.xgboost.round_result,
|
150 |
+
label='Round Result',
|
151 |
+
interactive=True)
|
152 |
+
|
153 |
+
checkbox__xgboost_round.change(
|
154 |
+
app.checkbox__xgboost_round__change,
|
155 |
+
[checkbox__xgboost_round],
|
156 |
+
[]
|
157 |
+
)
|
158 |
+
|
159 |
+
with gr.Row():
|
160 |
+
with gr.Column():
|
161 |
+
textbox__xgboost_params = gr.Textbox(
|
162 |
+
interactive=True,
|
163 |
+
value=app.xgboost_params)
|
164 |
+
|
165 |
+
btn__set_xgboost_params = gr.Button("Set Params")
|
166 |
+
|
167 |
+
json_xgboost_params = gr.JSON(
|
168 |
+
value=app.xgboost_params,
|
169 |
+
**args.json_xgboost_params)
|
170 |
+
|
171 |
+
btn__set_xgboost_params.click(
|
172 |
+
app.btn__set_xgboost_params__click,
|
173 |
+
[textbox__xgboost_params],
|
174 |
+
[json_xgboost_params])
|
175 |
+
|
176 |
+
btn__train_xgboost = gr.Button("Forecast with XGBoost Model")
|
177 |
+
|
178 |
+
plot__xgboost_result = gr.Plot()
|
179 |
+
|
180 |
+
with gr.Row():
|
181 |
+
df__xgboost_result = gr.Dataframe()
|
182 |
+
file__xgboost_result = gr.File()
|
183 |
+
|
184 |
+
btn__train_xgboost.click(
|
185 |
+
app.btn__train_xgboost__click,
|
186 |
+
[],
|
187 |
+
[plot__xgboost_result,
|
188 |
+
file__xgboost_result,
|
189 |
+
df__xgboost_result])
|
190 |
+
|
191 |
+
# ------- #
|
192 |
+
# Prophet #
|
193 |
+
# ------- #
|
194 |
+
with gr.Tab('Prophet'):
|
195 |
+
gr.Markdown('Prophet')
|
196 |
+
|
197 |
+
btn__forecast_with_prophet = gr.Button(
|
198 |
+
**args.btn__forecast_with_prophet)
|
199 |
+
|
200 |
+
plot__prophet_result = gr.Plot()
|
201 |
+
|
202 |
+
with gr.Row():
|
203 |
+
df__prophet_result = gr.DataFrame()
|
204 |
+
file__prophet_result = gr.File()
|
205 |
+
|
206 |
+
btn__forecast_with_prophet.click(
|
207 |
+
app.btn__forecast_with_prophet__click,
|
208 |
+
[],
|
209 |
+
[plot__prophet_result,
|
210 |
+
file__prophet_result,
|
211 |
+
df__prophet_result]
|
212 |
+
)
|
213 |
+
|
214 |
+
# --------- #
|
215 |
+
# Operators #
|
216 |
+
# --------- #
|
217 |
+
|
218 |
+
file__historical.upload(
|
219 |
+
app.file__historical__upload,
|
220 |
+
[file__historical],
|
221 |
+
[df__table_view,
|
222 |
+
dropdown__chart_view_filter,
|
223 |
+
dropdown__seasonality_decompose,
|
224 |
+
plot__chart_view])
|
225 |
+
|
226 |
+
file__future.upload(
|
227 |
+
app.file__future__upload,
|
228 |
+
[file__future],
|
229 |
+
[df__table_view,
|
230 |
+
dropdown__chart_view_filter,
|
231 |
+
dropdown__seasonality_decompose,
|
232 |
+
plot__chart_view,
|
233 |
+
number__n_predict])
|
234 |
+
|
235 |
+
btn__fit_data.click(
|
236 |
+
app.btn__fit_data__click,
|
237 |
+
[],
|
238 |
+
[
|
239 |
+
number__n_predict,
|
240 |
+
number__window_length,
|
241 |
+
file__historical,
|
242 |
+
file__future,
|
243 |
+
btn__fit_data,
|
244 |
+
column__models,
|
245 |
+
btn__load_historical_demo,
|
246 |
+
btn__load_future_demo,
|
247 |
+
md__forecast_data_info,
|
248 |
+
])
|
249 |
+
|
250 |
+
btn__load_historical_demo.click(
|
251 |
+
app.btn__load_historical_demo__click,
|
252 |
+
[],
|
253 |
+
[df__table_view,
|
254 |
+
dropdown__chart_view_filter,
|
255 |
+
dropdown__seasonality_decompose,
|
256 |
+
plot__chart_view,]
|
257 |
+
)
|
258 |
+
|
259 |
+
btn__load_future_demo.click(
|
260 |
+
app.btn__load_future_demo__click,
|
261 |
+
[],
|
262 |
+
[df__table_view,
|
263 |
+
dropdown__chart_view_filter,
|
264 |
+
dropdown__seasonality_decompose,
|
265 |
+
plot__chart_view,
|
266 |
+
number__n_predict]
|
267 |
+
)
|
268 |
+
|
269 |
+
dropdown__chart_view_filter.change(
|
270 |
+
app.dropdown__chart_view_filter__change,
|
271 |
+
[dropdown__chart_view_filter],
|
272 |
+
[plot__chart_view]
|
273 |
+
)
|
274 |
+
|
275 |
+
demo.launch()
|
gr_app/GradioApp.py
CHANGED
@@ -26,7 +26,7 @@ class GradioApp():
|
|
26 |
|
27 |
self.skus = self.ts_data['sku'].unique().tolist()
|
28 |
|
29 |
-
self.model_data = pd.
|
30 |
{
|
31 |
'sku': self.skus,
|
32 |
'best_model': '',
|
|
|
26 |
|
27 |
self.skus = self.ts_data['sku'].unique().tolist()
|
28 |
|
29 |
+
self.model_data = pd.DataFame(
|
30 |
{
|
31 |
'sku': self.skus,
|
32 |
'best_model': '',
|
gr_app/__pycache__/GradioApp.cpython-310.pyc
CHANGED
Binary files a/gr_app/__pycache__/GradioApp.cpython-310.pyc and b/gr_app/__pycache__/GradioApp.cpython-310.pyc differ
|
|