lte__
lte__

Reputation: 7576

SKLearn - Cannot import LinearModel?

I'm trying to import LinearModel from SKLearn:

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. Why? How can I fix this?

ImportError: cannot import name 'LinearModel'

Upvotes: 3

Views: 1519

Answers (2)

Dave Liu
Dave Liu

Reputation: 1132

As of sklearn v24 the previous solution from sklearn.linear_model.base import LinearModel doesn't work anymore.

New workaround is to import whatever class you need/want to inherit directly. For me, that was from sklearn.linear_model import LinearRegression

Upvotes: 1

tomsal
tomsal

Reputation: 133

What exactly are you trying to do? As far as I can see it, LinearModel is only a base class.

Is this maybe what you are looking for? 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. Import it using:

from sklearn.linear_model.base import LinearModel

Upvotes: 2

Related Questions