Skip to content

API fix params validation in SGD inherited models #20683

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

Merged
merged 16 commits into from
Aug 16, 2021

Conversation

glemaitre
Copy link
Member

@glemaitre glemaitre commented Aug 5, 2021

partly addressing #12652
partly superseding #16945

Remove parameters validation from places other than fit and partial_fit to follow our API.

I refactored the tests to use pytest parametrization. However, I did not remove any tests.
I added the validation of the parameters for the PassiveAggressive estimators.

The changes as mainly due to renaming klass to SGDEstimator for consistency.

@glemaitre glemaitre changed the title API fix params validation in SGD models API fix params validation in SGD inherited models Aug 5, 2021
@glemaitre
Copy link
Member Author

@adrinjalali would you be interested to have a look at this :)

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like to have a local variable named SGDEstimator with upper case. I would rather use a explicit local variable name such as estimator_type (or estimator_class) or sgd_estimator_type if want to be extra explicit.

@ogrisel
Copy link
Member

ogrisel commented Aug 5, 2021

Other than that, LGTM.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A ton of the changes are not related to this PR though, they're just the rename of the variable, but I'm okay with that, it just made the review a bit harder.

@glemaitre
Copy link
Member Author

I don't really like to have a local variable named SGDEstimator with upper case. I would rather use a explicit local variable name such as estimator_type (or estimator_class) or sgd_estimator_type if want to be extra explicit.

Since this is a class name, does it not make sense to use the CapWords convention?

@ogrisel
Copy link
Member

ogrisel commented Aug 6, 2021

Since this is a class name, does it not make sense to use the CapWords convention?

It's not the name of any class. There is no scikit-learn class with "SGDEstimator" in its __name__ attribute and it's not possible to do from sklearn.linear_model import SGDEstimator. It's the name of a local variable that refers to a class definition with name either SGDClassifier, SGDRegressor....

@ogrisel
Copy link
Member

ogrisel commented Aug 6, 2021

+1 for reverting the change to the local variable name to keep the diff clean and focused on the main matter of PR.

@glemaitre
Copy link
Member Author

I reverting the changes. Now, it looks like a PR that @lorentzenchr will like :P

@adrinjalali
Copy link
Member

O_o do we have an issue for this? is it related to this PR?

ImportError while importing test module '/home/circleci/project/sklearn/utils/tests/test_estimator_html_repr.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/circleci/.pyenv/versions/3.9.1/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
sklearn/utils/tests/test_estimator_html_repr.py:8: in <module>
    from sklearn.neural_network import MLPClassifier
sklearn/neural_network/__init__.py:10: in <module>
    from ._multilayer_perceptron import MLPClassifier
sklearn/neural_network/_multilayer_perceptron.py:9: in <module>
    from tkinter.tix import Tree
/opt/circleci/.pyenv/versions/3.9.1/lib/python3.9/tkinter/__init__.py:37: in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
E   ModuleNotFoundError: No module named '_tkinter'
!!!!!!!!!!!!!!!!!!! Interrupted: 21 errors during collection !!!!!!!!!!!!!!!!!!!

@glemaitre
Copy link
Member Author

@adrinjalali nop this is linked with #20691 due to my autocomplete vs code import system that I just deactivated :)

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glemaitre glemaitre merged commit d44fd44 into scikit-learn:main Aug 16, 2021
@glemaitre
Copy link
Member Author

Merging since we have a +2 and the comments have been addresed.

@lorentzenchr
Copy link
Member

Now, it looks like a PR that @lorentzenchr will like :P

+137 and -168 and make something in scikit-learn indeed scikit-learn API compliant (❓❗), yes 👍 .

@adrinjalali
Copy link
Member

Welcome to historical reasons @lorentzenchr 😁

@lorentzenchr
Copy link
Member

We should learn from history:smirk:

samronsin pushed a commit to samronsin/scikit-learn that referenced this pull request Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants