Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] macro_averaged_mean_absolute_error() raises ValueError #1094

Open
stephengmatthews opened this issue Sep 10, 2024 · 0 comments
Open

[BUG] macro_averaged_mean_absolute_error() raises ValueError #1094

stephengmatthews opened this issue Sep 10, 2024 · 0 comments

Comments

@stephengmatthews
Copy link

stephengmatthews commented Sep 10, 2024

Describe the bug

imblearn.metrics.macro_averaged_mean_absolute_error() raises an exception when not all classes are represented in the ground truth.

Thought I'd flag this because a similar function in sklearn behaves differently to imbalanced-learn. That function is f1_score with macro averaging. Here's an example of how no exception is raised:

from sklearn.metrics import f1_score

print(f1_score([0, 1], [0, 0], average="macro"))
print(f1_score([0, 0], [0, 1], average="macro"))

Note that issue #912 had the same exception but I'm uncertain whether it's related.

Steps/Code to Reproduce

from imblearn.metrics import macro_averaged_mean_absolute_error

print(macro_averaged_mean_absolute_error([0, 1], [0, 0]))
print(macro_averaged_mean_absolute_error([0, 0], [0, 1]))

Expected Results

0.5
0.75

Actual Results

0.5
*** ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.

Versions

System:
python: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
executable: /usr/bin/python
machine: Linux-6.5.0-45-generic-x86_64-with-glibc2.35

Python dependencies:
sklearn: 1.5.1
pip: 24.2
setuptools: 70.3.0
numpy: 1.26.4
scipy: 1.14.0
Cython: 3.0.11
pandas: 2.2.2
matplotlib: 3.9.2
joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
user_api: blas
internal_api: openblas
num_threads: 64
prefix: libopenblas
filepath: /usr/local/lib/python3.10/dist-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so
version: 0.3.23.dev
threading_layer: pthreads
architecture: SkylakeX

user_api: blas
internal_api: openblas
num_threads: 64
prefix: libscipy_openblas
filepath: /usr/local/lib/python3.10/dist-packages/scipy.libs/libscipy_openblas-c128ec02.so
version: 0.3.27.dev
threading_layer: pthreads
architecture: SkylakeX

user_api: openmp
internal_api: openmp
num_threads: 64
prefix: libgomp
filepath: /usr/local/lib/python3.10/dist-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
version: None

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant