diff --git a/nbs/losses.ipynb b/nbs/losses.ipynb index 6bc3be9..72adabd 100644 --- a/nbs/losses.ipynb +++ b/nbs/losses.ipynb @@ -652,7 +652,6 @@ " .sub(df[target_col], axis=0)\n", " .abs()\n", " .div(_zero_to_nan(df[target_col].abs()), axis=0)\n", - " .fillna(0)\n", " .groupby(df[id_col], observed=True).mean()\n", " )\n", " res.index.name = id_col\n", @@ -662,7 +661,7 @@ " abs_err = pl.col(target_col).sub(pl.col(model)).abs()\n", " abs_target = _zero_to_nan(pl.col(target_col))\n", " ratio = abs_err.truediv(abs_target).alias(model)\n", - " return ratio.fill_nan(0)\n", + " return ratio.fill_nan(None)\n", "\n", " res = _pl_agg_expr(df, models, id_col, gen_expr)\n", " return res" diff --git a/settings.ini b/settings.ini index 0df391f..b91719a 100644 --- a/settings.ini +++ b/settings.ini @@ -29,7 +29,7 @@ user = Nixtla requirements = numpy packaging pandas>=1.1.1 plotting_requirements = pandas[plot] plotly plotly-resampler scalers_requirements = numba scipy -polars_requirements = polars +polars_requirements = polars numpy<2 dev_requirements = datasetsforecast==0.0.8 nbdev pyarrow readme_nb = index.ipynb allowed_metadata_keys = diff --git a/utilsforecast/losses.py b/utilsforecast/losses.py index 2b80d7f..1c6ec4b 100644 --- a/utilsforecast/losses.py +++ b/utilsforecast/losses.py @@ -171,7 +171,6 @@ def mape( .sub(df[target_col], axis=0) .abs() .div(_zero_to_nan(df[target_col].abs()), axis=0) - .fillna(0) .groupby(df[id_col], observed=True) .mean() ) @@ -183,7 +182,7 @@ def gen_expr(model): abs_err = pl.col(target_col).sub(pl.col(model)).abs() abs_target = _zero_to_nan(pl.col(target_col)) ratio = abs_err.truediv(abs_target).alias(model) - return ratio.fill_nan(0) + return ratio.fill_nan(None) res = _pl_agg_expr(df, models, id_col, gen_expr) return res