Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scaled_crps for pandas #74

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading