alexander-lazarin commited on
Commit
8c05129
·
1 Parent(s): 8dc3a0f

Change layout to vertical

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -53,6 +53,13 @@ def forecast_time_series(file):
53
  title='Original Time Series and Forecast with Confidence Intervals',
54
  xaxis_title='Date',
55
  yaxis_title='Values',
 
 
 
 
 
 
 
56
  hovermode='x unified'
57
  )
58
 
@@ -64,19 +71,24 @@ def forecast_time_series(file):
64
  # Return plot file path and YoY change
65
  return fig, f'Year-over-Year Change in Sum of Values: {yoy_change:.2%}', combined_file
66
 
67
- # Create Gradio interface
68
- interface = gr.Interface(
69
- theme=gr.themes.Monochrome(),
70
- fn=forecast_time_series,
71
- inputs=gr.File(label="Upload Time Series CSV"),
72
- outputs=[
73
- gr.Plot(label="Time Series + Forecast Chart"),
74
- gr.Text(label="YoY % Change"),
75
- gr.File(label="Download Combined Data CSV")
76
- ],
77
- title="Time Series Forecasting",
78
- description="Upload a CSV file with a time series to forecast the next 24 periods and see the YoY % change. Download the combined original and forecast data."
79
- )
 
 
 
 
 
80
 
81
  # Launch the interface
82
  interface.launch()
 
53
  title='Original Time Series and Forecast with Confidence Intervals',
54
  xaxis_title='Date',
55
  yaxis_title='Values',
56
+ legend=dict(
57
+ orientation='h',
58
+ yanchor='bottom',
59
+ y=1.02,
60
+ xanchor='right',
61
+ x=1
62
+ ),
63
  hovermode='x unified'
64
  )
65
 
 
71
  # Return plot file path and YoY change
72
  return fig, f'Year-over-Year Change in Sum of Values: {yoy_change:.2%}', combined_file
73
 
74
+ # Create Gradio interface using Blocks
75
+ with gr.Blocks(theme=gr.themes.Monochrome()) as interface:
76
+ gr.Markdown("# Time Series Forecasting")
77
+ gr.Markdown("Upload a CSV file with a time series to forecast the next 24 periods and see the YoY % change. Download the combined original and forecast data.")
78
+
79
+ with gr.Row():
80
+ file_input = gr.File(label="Upload Time Series CSV")
81
+
82
+ with gr.Row():
83
+ plot_output = gr.Plot(label="Time Series + Forecast Chart")
84
+
85
+ with gr.Row():
86
+ yoy_output = gr.Text(label="YoY % Change")
87
+
88
+ with gr.Row():
89
+ csv_output = gr.File(label="Download Combined Data CSV")
90
+
91
+ file_input.change(forecast_time_series, inputs=file_input, outputs=[plot_output, yoy_output, csv_output])
92
 
93
  # Launch the interface
94
  interface.launch()