From 168bb0a5d731cd091cdc69291285f5221e9a9271 Mon Sep 17 00:00:00 2001 From: martinb-bb <105685594+martinb-bb@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:48:38 -0500 Subject: [PATCH] trans metric --- openbb_terminal/forecast/trans_model.py | 4 ++++ openbb_terminal/forecast/trans_view.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/openbb_terminal/forecast/trans_model.py b/openbb_terminal/forecast/trans_model.py index ac89b255820..21cac569567 100644 --- a/openbb_terminal/forecast/trans_model.py +++ b/openbb_terminal/forecast/trans_model.py @@ -40,6 +40,7 @@ def get_trans_data( model_save_name: str = "trans_model", force_reset: bool = True, save_checkpoints: bool = True, + metric: str = "mape", ) -> Tuple[ Optional[List[TimeSeries]], Optional[List[TimeSeries]], @@ -94,6 +95,8 @@ def get_trans_data( discarded). Defaults to True. 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 ------- @@ -176,4 +179,5 @@ def get_trans_data( train_split, forecast_horizon, n_predict, + metric, ) diff --git a/openbb_terminal/forecast/trans_view.py b/openbb_terminal/forecast/trans_view.py index fda46a687a6..4ca64c1b5b4 100644 --- a/openbb_terminal/forecast/trans_view.py +++ b/openbb_terminal/forecast/trans_view.py @@ -47,6 +47,7 @@ def display_trans_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 Transformer forecast @@ -112,6 +113,10 @@ def display_trans_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 """ @@ -152,6 +157,7 @@ def display_trans_forecast( model_save_name=model_save_name, force_reset=force_reset, save_checkpoints=save_checkpoints, + metric=metric, ) if ticker_series == []: return @@ -176,6 +182,7 @@ def display_trans_forecast( naive=naive, export_pred_raw=export_pred_raw, external_axes=external_axes, + metric=metric, ) if residuals: helpers.plot_residuals(