Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
from core.data import load_data
|
| 4 |
from core.model_runner import get_model
|
| 5 |
-
from core.plot import plot_forecast,
|
| 6 |
from config import AVAILABLE_MODELS, DEFAULT_TICKERS
|
| 7 |
|
| 8 |
|
|
@@ -39,8 +39,8 @@ def main_interface():
|
|
| 39 |
backtest_plot = gr.Plot(label="๐ Backtesting: Actual vs Forecast")
|
| 40 |
future_plot = gr.Plot(label="๐ฎ Future Forecast with Actuals")
|
| 41 |
future_table = gr.Dataframe(label="๐ Future Predictions")
|
| 42 |
-
|
| 43 |
-
|
| 44 |
loss_plot = gr.Plot(label="๐ Training Loss Curve")
|
| 45 |
|
| 46 |
def run_pipeline(data_src, ticker, file_upload, start_date, end_date, horizon, model,
|
|
@@ -58,7 +58,7 @@ def main_interface():
|
|
| 58 |
|
| 59 |
result = get_model(
|
| 60 |
df=main_df,
|
| 61 |
-
future_df=future_df,
|
| 62 |
model_name=model,
|
| 63 |
horizon=horizon,
|
| 64 |
hidden_units=hidden_units,
|
|
@@ -73,9 +73,9 @@ def main_interface():
|
|
| 73 |
test_split=test_split
|
| 74 |
)
|
| 75 |
forecast_plot = plot_forecast(result)
|
| 76 |
-
future_plot = plot_future_forecast(main_df, result, future_df)
|
| 77 |
-
|
| 78 |
-
|
| 79 |
loss_plot = plot_loss_curve(result)
|
| 80 |
|
| 81 |
msg = "โ
Done."
|
|
@@ -90,7 +90,7 @@ def main_interface():
|
|
| 90 |
else:
|
| 91 |
future_df_out = pd.DataFrame()
|
| 92 |
|
| 93 |
-
return forecast_plot, future_plot, future_df_out,
|
| 94 |
except Exception as e:
|
| 95 |
return None, None, None, None, None, None, f"โ Error: {str(e)}"
|
| 96 |
|
|
@@ -102,7 +102,7 @@ def main_interface():
|
|
| 102 |
hidden_units, n_layers, epochs, learning_rate,
|
| 103 |
beta1, beta2, weight_decay, dropout, window_size, test_split
|
| 104 |
],
|
| 105 |
-
outputs=[backtest_plot, future_plot, future_table,
|
| 106 |
)
|
| 107 |
|
| 108 |
def toggle_file(src):
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from core.data import load_data
|
| 4 |
from core.model_runner import get_model
|
| 5 |
+
from core.plot import plot_forecast, plot_metrics_precision, plot_metrics_risk, plot_loss_curve, plot_future_forecast
|
| 6 |
from config import AVAILABLE_MODELS, DEFAULT_TICKERS
|
| 7 |
|
| 8 |
|
|
|
|
| 39 |
backtest_plot = gr.Plot(label="๐ Backtesting: Actual vs Forecast")
|
| 40 |
future_plot = gr.Plot(label="๐ฎ Future Forecast with Actuals")
|
| 41 |
future_table = gr.Dataframe(label="๐ Future Predictions")
|
| 42 |
+
precision_plot = gr.Plot(label="๐ Precision Metrics (Model Accuracy: Rยฒ, Explained Variance, MDA)")
|
| 43 |
+
risk_plot = gr.Plot(label="๐ Risk Metrics (Error Magnitude: RMSE, MAE, MAPE, MASE)")
|
| 44 |
loss_plot = gr.Plot(label="๐ Training Loss Curve")
|
| 45 |
|
| 46 |
def run_pipeline(data_src, ticker, file_upload, start_date, end_date, horizon, model,
|
|
|
|
| 58 |
|
| 59 |
result = get_model(
|
| 60 |
df=main_df,
|
| 61 |
+
future_df=future_df,
|
| 62 |
model_name=model,
|
| 63 |
horizon=horizon,
|
| 64 |
hidden_units=hidden_units,
|
|
|
|
| 73 |
test_split=test_split
|
| 74 |
)
|
| 75 |
forecast_plot = plot_forecast(result)
|
| 76 |
+
future_plot = plot_future_forecast(main_df, result, future_df)
|
| 77 |
+
precision_plot = plot_metrics_precision(result)
|
| 78 |
+
risk_plot = plot_metrics_risk(result)
|
| 79 |
loss_plot = plot_loss_curve(result)
|
| 80 |
|
| 81 |
msg = "โ
Done."
|
|
|
|
| 90 |
else:
|
| 91 |
future_df_out = pd.DataFrame()
|
| 92 |
|
| 93 |
+
return forecast_plot, future_plot, future_df_out, precision_plot, risk_plot, loss_plot, msg
|
| 94 |
except Exception as e:
|
| 95 |
return None, None, None, None, None, None, f"โ Error: {str(e)}"
|
| 96 |
|
|
|
|
| 102 |
hidden_units, n_layers, epochs, learning_rate,
|
| 103 |
beta1, beta2, weight_decay, dropout, window_size, test_split
|
| 104 |
],
|
| 105 |
+
outputs=[backtest_plot, future_plot, future_table, precision_plot, risk_plot, loss_plot, status]
|
| 106 |
)
|
| 107 |
|
| 108 |
def toggle_file(src):
|