[英]SKLearn - Cannot import LinearModel?
I'm trying to import LinearModel
from SKLearn:我正在尝试从 SKLearn 导入LinearModel
:
from sklearn.base import RegressorMixin, LinearModel
I can see with my own eyes, that the class is in base.py
here , but the import doesn't work.我可以用自己的眼睛看,那类在base.py
这里,但进口不起作用。 Why?为什么? How can I fix this?我怎样才能解决这个问题?
ImportError: cannot import name 'LinearModel'
What exactly are you trying to do?你到底想做什么? As far as I can see it, LinearModel is only a base class.在我看来,LinearModel 只是一个基类。
Is this maybe what you are looking for?这可能是您要找的吗? http://scikit-learn.org/stable/modules/linear_model.html#ordinary-least-squares http://scikit-learn.org/stable/modules/linear_model.html#ordinary-least-squares
Edit:编辑:
Oh and by the way, if you really need the base class, I believe it is located in sklearn.linear_model.base.哦,顺便说一句,如果你真的需要基类,我相信它位于 sklearn.linear_model.base 中。 Import it using:使用以下命令导入它:
from sklearn.linear_model.base import LinearModel
As of sklearn v24 the previous solution from sklearn.linear_model.base import LinearModel
doesn't work anymore. from sklearn.linear_model.base import LinearModel
的先前解决方案不再起作用。
New workaround is to import whatever class you need/want to inherit directly.新的解决方法是导入您需要/想要直接继承的任何类。 For me, that was from sklearn.linear_model import LinearRegression
对我来说,那是from sklearn.linear_model import LinearRegression
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.