Spaces:
Sleeping
Sleeping
added the backtest and limit forecasts
Browse files
app.py
CHANGED
@@ -202,6 +202,8 @@ def get_forecast(period_: str, pred_model: str):
|
|
202 |
df_110.rename(columns={'common_unit_price': 'Upper_Limit'},inplace=True)
|
203 |
merged_df = pd.merge(df_90,df_, on=['Date']).merge(df_110, on=['Date'])
|
204 |
merged_df = merged_df.reset_index()
|
|
|
|
|
205 |
|
206 |
|
207 |
start=pd.Timestamp("20180131")
|
@@ -216,9 +218,15 @@ def get_forecast(period_: str, pred_model: str):
|
|
216 |
)
|
217 |
series_time = series_transformed[-len(backtest_series_):].time_index
|
218 |
series_vals = (transformer.inverse_transform(series_transformed[-len(backtest_series_):])).values()
|
219 |
-
df_series = pd.DataFrame(data={'
|
220 |
vals = (transformer.inverse_transform(backtest_series_)).values()
|
221 |
-
df_backtest = pd.DataFrame(data={'
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
|
224 |
# Create figure
|
@@ -303,7 +311,7 @@ def main():
|
|
303 |
"""
|
304 |
**Timeseries Forecasting model Temporal Fusion Transformer(TFT) built on Darts library**.
|
305 |
""")
|
306 |
-
commodity = gr.Radio(["Wheat Price Forecasting"
|
307 |
period = gr.Radio(['3 months',"6 months"],label="Forecast horizon")
|
308 |
|
309 |
# with gr.Row():
|
|
|
202 |
df_110.rename(columns={'common_unit_price': 'Upper_Limit'},inplace=True)
|
203 |
merged_df = pd.merge(df_90,df_, on=['Date']).merge(df_110, on=['Date'])
|
204 |
merged_df = merged_df.reset_index()
|
205 |
+
|
206 |
+
merged_df.to_csv('data/afghan_wheatfcasts.csv',index=False)
|
207 |
|
208 |
|
209 |
start=pd.Timestamp("20180131")
|
|
|
218 |
)
|
219 |
series_time = series_transformed[-len(backtest_series_):].time_index
|
220 |
series_vals = (transformer.inverse_transform(series_transformed[-len(backtest_series_):])).values()
|
221 |
+
df_series = pd.DataFrame(data={'Date': series_time, 'actual_prices': series_vals.ravel() })
|
222 |
vals = (transformer.inverse_transform(backtest_series_)).values()
|
223 |
+
df_backtest = pd.DataFrame(data={'Date': backtest_series_.time_index, 'historical_forecasts': vals.ravel() })
|
224 |
+
|
225 |
+
|
226 |
+
# df_backtest_wheat = pd.DataFrame(data={'Date': backtest_series_.time_index, 'historical_wheat_forecasts': vals.ravel() })
|
227 |
+
df_wheat_output = pd.merge(df_series,df_backtest[['Date',"historical_forecasts"]],on=['Date'],how='left')
|
228 |
+
df_wheat_output.to_csv('data/aghanwheat_allhistorical.csv',index=False)
|
229 |
+
|
230 |
|
231 |
|
232 |
# Create figure
|
|
|
311 |
"""
|
312 |
**Timeseries Forecasting model Temporal Fusion Transformer(TFT) built on Darts library**.
|
313 |
""")
|
314 |
+
commodity = gr.Radio(["Wheat Price Forecasting"],label="Commodity to Forecast")
|
315 |
period = gr.Radio(['3 months',"6 months"],label="Forecast horizon")
|
316 |
|
317 |
# with gr.Row():
|