8000 [BUG] Upcoming changes to `scipy.stats.mode` in 1.11 · Issue #937 · scikit-learn-contrib/imbalanced-learn · GitHub
[go: up one dir, main page]

Skip to content

[BUG] Upcoming changes to scipy.stats.mode in 1.11 #937

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

Closed
hayesall opened this issue Nov 12, 2022 · 0 comments · Fixed by #938
Closed

[BUG] Upcoming changes to scipy.stats.mode in 1.11 #937

hayesall opened this issue Nov 12, 2022 · 0 comments · Fixed by #938
Labels
Type: Bug Indicates an unexpected problem or unintended behavior

Comments

@hayesall
Copy link
Member

Describe the bug

scipy.stats.mode adds a FutureWarning in 1.9 for an upcoming API change:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mode.html

Steps/Code to Reproduce

from collections import Counter
import numpy as np
from imblearn.over_sampling import SMOTEN

X = np.array(["A"] * 10 + ["B"] * 20 + ["C"] * 30, dtype=object).reshape(-1, 1)
y = np.array([0] * 20 + [1] * 40, dtype=np.int32)

sampler = SMOTEN(random_state=0)
X_res, y_res = sampler.fit_resample(X, y)

print(f"Class counts after resampling {Counter(y_res)}")

Actual Results

/home/hayesall/imbalanced-learn/imblearn/over_sampling/_smote/base.py:789: FutureWarning: Unlike other reduction functions (e.g. `skew`, `kurtosis`), the default behavior of `mode` typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of `keepdims` will become False, the `axis` over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set `keepdims` to True or False to avoid this warning.
  stats.mode(X_class[nn_indices[samples_indices]], axis=1).mode, axis=1

Versions

System, Dependency Information

System Information

  • python : 3.8.13 (default, Oct 21 2022, 23:50:54) [GCC 11.2.0]
  • executable: /home/hayesall/miniconda3/envs/imblearn/bin/python
  • machine : Linux-5.10.142-19739-g5899aa8f604c-x86_64-with-glibc2.17

Python Dependencies

  • pip : 22.2.2
  • setuptools: 65.5.0
  • imblearn : 0.10.0.dev0
  • sklearn : 1.1.3
  • numpy : 1.23.4
  • scipy : 1.9.3
  • Cython : None
  • pandas : None
  • keras : None
  • tensorflow: None
  • joblib : 1.2.0
@hayesall hayesall added the Type: Bug Indicates an unexpected problem or unintended behavior label Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0