from sklearn.linear_model import LinearRegression
在Jupyter Notebook中给我这个错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-127-36ba82e2d702> in <module>()
----> 1 from sklearn.linear_model import LinearRegression
2
3 lin_reg = LinearRegression()
4 lin_reg.fit(housing_prepared, housing_labels)
C:\Users\David\Anaconda2\lib\site-packages\sklearn\linear_model\__init__.py in <module>()
19 MultiTaskElasticNet, MultiTaskElasticNetCV,
20 MultiTaskLassoCV)
---> 21 from .huber import HuberRegressor
22 from .sgd_fast import Hinge, Log, ModifiedHuber, SquaredLoss, Huber
23 from .stochastic_gradient import SGDClassifier, SGDRegressor
C:\Users\David\Anaconda2\lib\site-packages\sklearn\linear_model\huber.py in <module>()
10 from ..utils import check_X_y
11 from ..utils import check_consistent_length
---> 12 from ..utils import axis0_safe_slice
13 from ..utils.extmath import safe_sparse_dot
14
ImportError: cannot import name axis0_safe_slice
我可以从sklearn.preprocessing导入东西。谢谢你的帮助!
答案 0 :(得分:1)
不知道具体问题是什么,但卸载并重新安装scikit-learn为我解决了这个问题:
pip uninstall scikit-learn
pip install scikit-learn