AttributeError: module 'sklearn' has no attribute 'linear_model'
程序员文章站
2022-07-14 15:14:43
...
AttributeError: module 'sklearn' has no attribute 'linear_model'
- 在调用sklearn库的时候出现Traceback错误。
import sklearn
model = sklearn.linear_model.LinearRegression()
- 错误如图所示:
Traceback (most recent call last):
File "/Users/zhangzhenkai/Documents/TensorflowLearn/ch1/sec1/Scikit_Learn.py", line 37, in <module>
model = sklearn.linear_model.LinearRegression()
AttributeError: module 'sklearn' has no attribute 'linear_model'
- 后来在Google上搜了一下,找到了解决方法,只需将代码修改为:
from sklearn.linear_model import LinearRegression
model = sklearn.linear_model.LinearRegression()
- 同样地,AttributeError: module ‘sklearn’ has no attribute ‘datasets’,也可以这样解决。
AttributeError: module 'sklearn' has no attribute 'datasets'
推荐阅读
-
AttributeError: module ‘community‘ has no attribute ‘best_partition‘ 问题解决方法
-
module ‘community‘ has no attribute ‘best_partition‘ [已解决]
-
【python】解决AttributeError: module ‘scipy.misc‘ has no attribute ‘toimage‘问题
-
【Tensorflow】Linux下Tensorflow报错:AttributeError: module ‘tensorflow‘ has no attribute ‘xxxx‘
-
AttributeError: 'module' object has no attribute 'main'
-
AttributeError: module 'sklearn' has no attribute 'linear_model'
-
解决Keras报错AttributeError: 'NoneType' object has no attribute 'inbound_nodes'
-
AttributeError: ‘NoneType‘ object has no attribute ‘origin‘解决办法
-
AttributeError: ‘set‘ object has no attribute ‘append‘解决办法
-
'module' object has no attribute