-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
SGDRegressor is not inheriting from LinearModel #31315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, I believe it was historically written independently of other linear models. Maybe subclassing from the base class could allow for some code reuse, although I have not checked. Note that the |
If subclassing can help remove redundant code, then I am not opposed to a PR. But if subclassing does not help reduce code complexity, I see little benefit to doing so. Extra indirections introduced by inheritance make it harder to navigate the code base and (slightly) hurt code readability as a result. |
I looked a bit at the code and I think that we can clean-up something. In addition of the inheritance, I think we should look at the code of scikit-learn/sklearn/linear_model/_base.py Lines 322 to 324 in 81bb708
I think there is room to improve the clarity of those classes and it should remove some redundant code, notably when it comes to the |
Describe the bug
I wanted to rely on the base class LinearModel to identify linear models, but I found out that SGDRegressor (nor any of its sub classes) is not inheriting this class. However, SGDClassifier is (through LinearClassifierMixin).
Is there any reason for BaseSGDRegressor to not inherit LinearModel? Is it because it overloads all of LinearModel's methods?
Steps/Code to Reproduce
from sklearn.linear_model import SGDRegressor
from sklearn.linear_model._base import LinearModel
issubclass(SGDRegressor, LinearModel)
Expected Results
from sklearn.linear_model import SGDRegressor
from sklearn.linear_model._base import LinearModel
issubclass(SGDRegressor, LinearModel)
True
Actual Results
from sklearn.linear_model import SGDRegressor
from sklearn.linear_model._base import LinearModel
issubclass(SGDRegressor, LinearModel)
False
Versions
The text was updated successfully, but these errors were encountered: