When I try to import a DecisionTreeClassifier from sklearn.tree I receive the following attribute error: AttributeError: module 'numpy' has no attribute 'float'
My code is:
import sklearn
print(sklearn.__version__)
from sklearn.tree import DecisionTreeClassifier
Output:
0.23.2
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
You are getting this error because you are using np.float as a data type, which is no longer supported by NumPy. As the error message suggests, you should replace np.float with float or np.float64 in your code.
import numpy as np
a = np.array([1.2, 3.4, 5.6], dtype=float) # use float instead of
np.float
Please try this and five an update.