Skip to content

Commit

Permalink
fix scaled_crps for pandas (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Apr 9, 2024
1 parent c4d6229 commit e32b0a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions nbs/losses.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,7 @@
" sizes = ufp.counts_by_id(df, id_col)\n",
" if isinstance(loss, pd.DataFrame):\n",
" loss = loss.set_index(id_col)\n",
" sizes = sizes.set_index(id_col)\n",
" assert isinstance(df, pd.DataFrame)\n",
" norm = df[target_col].abs().groupby(df[id_col], observed=True).sum()\n",
" res = 2 * loss.mul(sizes['counts'], axis=0).div(norm + eps, axis=0)\n",
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DEFAULT]
repo = utilsforecast
lib_name = utilsforecast
version = 0.1.2
version = 0.1.3
min_python = 3.8
license = apache2
black_formatting = True
Expand Down
2 changes: 1 addition & 1 deletion utilsforecast/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.2"
__version__ = "0.1.3"
1 change: 1 addition & 0 deletions utilsforecast/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def scaled_crps(
sizes = ufp.counts_by_id(df, id_col)
if isinstance(loss, pd.DataFrame):
loss = loss.set_index(id_col)
sizes = sizes.set_index(id_col)
assert isinstance(df, pd.DataFrame)
norm = df[target_col].abs().groupby(df[id_col], observed=True).sum()
res = 2 * loss.mul(sizes["counts"], axis=0).div(norm + eps, axis=0)
Expand Down

0 comments on commit e32b0a7

Please sign in to comment.