scikit-learn-contrib / category_encoders

A library of sklearn compatible categorical variable encoders
http://contrib.scikit-learn.org/category_encoders/
BSD 3-Clause "New" or "Revised" License
2.4k stars 393 forks source link

Avoid `DeprecationWarning` of scipy #349

Closed wakabame closed 2 years ago

wakabame commented 2 years ago

After scipy@1.8.0, the scipy.sparse.csr namespace is deprecated. So category_encoders asserts the DeprecationWarning when it depends scipy:^1.8.0;

$ python -Wd 
Python 3.10.4 (main, Apr  6 2022, 00:48:19) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import category_encoders
(omitted)/python3.10/site-packages/category_encoders/utils.py:5: DeprecationWarning: Please use `csr_matrix` from the `scipy.sparse` namespace, the `scipy.sparse.csr` namespace is deprecated.
  from scipy.sparse.csr import csr_matrix
>>> category_encoders.__version__
'2.4.0'
>>> import scipy
>>> scipy.__version__
'1.8.0'

We need to use csr_matrix from the scipy.sparse namespace. This namespace exists at least scipy@1.0.0 until now (docs)

Proposed Changes

※ This is my first pull request, so I apologize if there are any problems. I would appreciate it if you could check it.

PaulWestenthanner commented 2 years ago

Thanks for your contribution. LGTM & merging