I am trying to import linear_model from sklearn
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
from sklearn import linear_model
but this shows an error of
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-1e48cdd03462> in <module>
4 import seaborn as sns
5 import sklearn
----> 6 from sklearn import linear_model
/usr/lib/python3/dist-packages/sklearn/linear_model/__init__.py in <module>
9 from ._base import LinearRegression
10 from ._bayes import BayesianRidge, ARDRegression
---> 11 from ._least_angle import (Lars, LassoLars, lars_path, lars_path_gram, LarsCV,
12 LassoLarsCV, LassoLarsIC)
13 from ._coordinate_descent import (Lasso, ElasticNet, LassoCV, ElasticNetCV,
/usr/lib/python3/dist-packages/sklearn/linear_model/_least_angle.py in <module>
32 @_deprecate_positional_args
33 def lars_path(X, y, Xy=None, *, Gram=None, max_iter=500, alpha_min=0,
---> 34 method='lar', copy_X=True, eps=np.finfo(np.float).eps,
35 copy_Gram=True, verbose=0, return_path=True,
36 return_n_iter=False, positive=False):
~/.local/lib/python3.9/site-packages/numpy/__init__.py in __getattr__(attr)
311
312 if attr in __former_attrs__:
--> 313 raise AttributeError(__former_attrs__[attr])
314
315 if attr == 'testing':
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
I dont seem to understand really whats going onn and what the issue with numpy while importing sklearn. I get that numpy is used in sklearn but i dont get how to fix this. This is running in jupyter-lab in linux-server machine
I tried uninstalling and installing the module but it doesn't fix the issue. Import sklearn doesnt return any error but importing linear_model does and maybe other more.