From 56eba54a3e69af664759633bfb2bdb345b811c6d Mon Sep 17 00:00:00 2001 From: martinb-bb <105685594+martinb-bb@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:40:05 -0500 Subject: [PATCH] tcn metrics --- openbb_terminal/forecast/tcn_model.py | 4 ++++ openbb_terminal/forecast/tcn_view.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/openbb_terminal/forecast/tcn_model.py b/openbb_terminal/forecast/tcn_model.py index 1d0c7467d39..fe4604b1404 100644 --- a/openbb_terminal/forecast/tcn_model.py +++ b/openbb_terminal/forecast/tcn_model.py @@ -37,6 +37,7 @@ def get_tcn_data( model_save_name: str = "tcn_model", force_reset: bool = True, save_checkpoints: bool = True, + metric: str = "mape", ) -> Tuple[ List[Optional[TimeSeries]], List[Optional[TimeSeries]], @@ -86,6 +87,8 @@ def get_tcn_data( save_checkpoints: bool Whether or not to automatically save the untrained model and checkpoints from training. Defaults to True. + metric: str + Metric to use for model selection. Defaults to "mape". Returns ------- @@ -166,4 +169,5 @@ def get_tcn_data( train_split, forecast_horizon, n_predict, + metric, ) diff --git a/openbb_terminal/forecast/tcn_view.py b/openbb_terminal/forecast/tcn_view.py index 5e7cf5aec94..13ff4003761 100644 --- a/openbb_terminal/forecast/tcn_view.py +++ b/openbb_terminal/forecast/tcn_view.py @@ -44,6 +44,7 @@ def display_tcn_forecast( end_date: Optional[datetime] = None, naive: bool = False, export_pred_raw: bool = False, + metric: str = "mape", external_axes: Optional[List[plt.axes]] = None, ): """Display TCN forecast @@ -104,6 +105,10 @@ def display_tcn_forecast( naive: bool Whether to show the naive baseline. This just assumes the closing price will be the same as the previous day's closing price. Defaults to False. + export_pred_raw: bool + Whether to export the raw predicted values. Defaults to False. + metric: str + The metric to use for the model. Defaults to "mape". external_axes: Optional[List[plt.axes]] External axes to plot on """ @@ -141,6 +146,7 @@ def display_tcn_forecast( model_save_name=model_save_name, force_reset=force_reset, save_checkpoints=save_checkpoints, + metric=metric, ) if ticker_series == []: return @@ -165,6 +171,7 @@ def display_tcn_forecast( naive=naive, export_pred_raw=export_pred_raw, external_axes=external_axes, + metric=metric, ) if residuals: helpers.plot_residuals(