darts icon indicating copy to clipboard operation
darts copied to clipboard

[BUG] Passing metric for grid search evaluation for series containing 0

Open albin02t opened this issue 3 years ago • 3 comments

Hi,

i want to apply grid search tuning using RandomForest but my train or val data may contain 0s in them in which case the default MAPE would fail. MASE can be used for calculating errrors in training data containing 0. But passing the mase function gives errors that i am not able to solve

To Reproduce:

        from darts.models.forecasting.random_forest import RandomForest
        from darts.metrics import mase
        rf_hyperparameters={'n_estimators':[100, 150, 200], 'lags': [5, 10, 15, 20, 25, 30]}
        m_random_forest = RandomForest.gridsearch(parameters=rf_hyperparameters, 
                                                  series=train,
                                                  val_series=val, metric=mase())

It gives the following error: TypeError: mase() missing 1 required positional argument: 'insample'

How can i use MASE for RandomForest gridsearch metric

System (please complete the following information):

Python version: 3.7.11
darts version: 0.18.0

albin02t avatar Jun 02 '22 19:06 albin02t

Hi @albin02t , the metric must be a callable accepting 2 TimeSeries as input arguments and that returns a float value.

Darts' mase has 3 positional input arguments including insample and can therefore not be used with gridsearch.

dennisbader avatar Jun 03 '22 07:06 dennisbader

Hi @dennisbader Okay got it. so for multiple timeseries which hav a alot of 0, I won't be able to apply grid search? Thanks for the quick replies

albin02t avatar Jun 03 '22 07:06 albin02t

You can with any other metrics that accepts two poisitonal input arguments (see all metrics here, like rmse, mse, mae, marre, ..)

Edit: as a heads up, multiple time series (list/sequence of time series) are not support by gridsearch.

dennisbader avatar Jun 03 '22 07:06 dennisbader