Spaces:
Runtime error
Runtime error
import gradio as gr | |
# from arguments import init_args | |
from gr_app.GradioApp import GradioApp | |
from gr_app import args | |
app = GradioApp() | |
demo = gr.Blocks(**args.block) | |
with demo: | |
warning = gr.Warning() | |
gr.Markdown('# Sentient.io - Demand Forecasting') | |
gr.Markdown('Demo for demand forecasting pipeline') | |
gr.Markdown('---') | |
gr.Markdown('# Step 1 - Load Data') | |
with gr.Row(): | |
gr.Markdown(''' | |
Use button "Load Demo Data" for a quick demo with pre-loaded data. For uploading your own data, please follow the below requirements. | |
### Data Requirements: | |
- Time series data have to be in CSV format | |
- Data must contains datetime, y and sku columns. | |
- Multiple SKUs can put in to same CSV | |
- Time interval in data must be consistent | |
- Missing value have to be filled up | |
''') | |
with gr.Column(): | |
btn_load_data = gr.Button('Load Demo Data') | |
gr.Markdown('------ or ------', | |
elem_classes="demo_app_text_center") | |
file_upload_data = gr.File(**args.file_upload_data) | |
df_ts_data = gr.DataFrame(**args.df_ts_data) | |
gr.Markdown('---') | |
gr.Markdown('# Step 2 - Model Selection') | |
with gr.Row(): | |
gr.Markdown(''' | |
Train and evaluate model, identify data characteristics and select the best performing model. This step only need to run when the market regime shifted or when need to to re-select the model. | |
- Click "Use Demo Data" Button if the demo data set has been loaded in Step 1 | |
- Else, directly proceed to model selection | |
- Only upload dataset if the model select process had been previously done, and you have save a copy of the CSV response. | |
''') | |
with gr.Column(): | |
btn_load_model_data = gr.Button('Use Demo Data') | |
btn_model_selection = gr.Button('Model Selection', variant='primary') | |
gr.Markdown('Upload previous model selection result (if have):') | |
file_upload_model_data = gr.File(**args.file_upload_model_data) | |
df_model_data = gr.DataFrame() | |
file_model_data = gr.File() | |
gr.Markdown('# Step 3 - Forecasting') | |
with gr.Row(): | |
gr.Markdown( | |
'This step only can be done when model selection process is completed.') | |
with gr.Column(): | |
gr.Markdown(''' | |
### Forecast Horizon | |
Max horizon will be 20% of provided data range. The unit will be same as the time series data time interval. | |
''') | |
slider_forecast_horizon = gr.Slider(**args.slider_forecast_horizon) | |
btn_forecast = gr.Button("Forecast", variant='primary') | |
df_forecast = gr.DataFrame(**args.df_forecast) | |
file_forecast = gr.File() | |
# ============= # | |
# = Functions = # | |
# ============= # | |
btn_load_data.click( | |
app.btn_load_data__click, | |
[], | |
[df_ts_data, df_model_data, file_model_data, slider_forecast_horizon]) | |
file_upload_data.upload( | |
app.file_upload_data__upload, | |
[file_upload_data], | |
[df_ts_data, df_model_data, file_model_data, slider_forecast_horizon]) | |
file_upload_model_data.upload( | |
app.file_upload_model_data__upload, | |
[file_upload_model_data], | |
[df_model_data, file_model_data] | |
) | |
btn_load_model_data.click( | |
app.btn_load_model_data__click, | |
[], [df_model_data, file_model_data] | |
) | |
btn_model_selection.click( | |
app.btn_model_selection__click, | |
[], [df_model_data, file_model_data]) | |
btn_forecast.click( | |
app.btn_forecast__click, | |
[], [df_forecast, file_forecast] | |
) | |
slider_forecast_horizon.change( | |
app.slider_forecast_horizon__update, | |
[slider_forecast_horizon], | |
[]) | |
demo.launch() | |