Closed
Description
Describe the bug
import numpy as np
import pandas as pd
import sklearn
from sklearn.ensemble import RandomForestClassifier
# 1.23.3 1.5.0 1.2.0
print(np.__version__, pd.__version__, sklearn.__version__)
x = np.random.random((20, 1))
y = x[:, 0] >= 0.3
x = pd.DataFrame(x) # remove these and it works
y = pd.Series(y) # remove these and it works
r = RandomForestClassifier()
r.fit(x, y)
yhat = r.predict(x)
assert np.issubdtype(yhat.dtype, np.bool_) # fails since scikit 1.2.0
Steps/Code to Reproduce
import numpy as np
import pandas as pd
import sklearn
from sklearn.ensemble import RandomForestClassifier
# 1.23.3 1.5.0 1.2.0
print(np.__version__, pd.__version__, sklearn.__version__)
x = np.random.random((20, 1))
y = x[:, 0] >= 0.3
x = pd.DataFrame(x) # remove these and it works
y = pd.Series(y) # remove these and it works
r = RandomForestClassifier()
r.fit(x, y)
yhat = r.predict(x)
print(yhat)
assert np.issubdtype(yhat.dtype, np.bool_) # fails since scikit 1.2.0
Expected Results
[True False False True ...]
Actual Results
[1. 0. 0. 1. ...]
Traceback (most recent call last):
File "/Users/XXX/PycharmProjects/flow/bla.py", line 21, in
assert np.issubdtype(yhat.dtype, np.bool_)
AssertionError
Versions
System:
python: 3.9.13 (main, Sep 21 2022, 15:17:17) [Clang 13.0.0 (clang-1300.0.29.30)]
executable: /Users/niklas.fruehauf/.pyenv/versions/flow-venv-3.9/bin/python
machine: macOS-12.6.1-x86_64-i386-64bit
Python dependencies:
sklearn: 1.2.0
pip: 22.3.1
setuptools: 59.8.0
numpy: 1.23.3
scipy: 1.8.1
Cython: 0.29.32
pandas: 1.5.0
matplotlib: 3.5.3
joblib: 1.2.0
threadpoolctl: 3.1.0
Built with OpenMP: True
threadpoolctl info:
user_api: blas
internal_api: openblas
prefix: libopenblas
filepath: /Users/niklas.fruehauf/.pyenv/versions/3.9.13/envs/flow-venv-3.9/lib/python3.9/site-packages/numpy/.dylibs/libopenblas64_.0.dylib
version: 0.3.20
threading_layer: pthreads
architecture: Haswell
num_threads: 6
user_api: openmp
internal_api: openmp
prefix: libomp
filepath: /Users/niklas.fruehauf/.pyenv/versions/3.9.13/envs/flow-venv-3.9/lib/python3.9/site-packages/sklearn/.dylibs/libomp.dylib
version: None
num_threads: 12
user_api: blas
internal_api: openblas
prefix: libopenblas
filepath: /Users/niklas.fruehauf/.pyenv/versions/3.9.13/envs/flow-venv-3.9/lib/python3.9/site-packages/scipy/.dylibs/libopenblas.0.dylib
version: 0.3.17
threading_layer: pthreads
architecture: Haswell
num_threads: 6