-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[FIX] sgd: Change deprecated n_iter to max_iter #2920
Conversation
Orange/widgets/model/owsgd.py
Outdated
@@ -76,7 +76,7 @@ class Outputs(OWBaseLearner.Outputs): | |||
learning_rate_index = Setting(0) | |||
eta0 = Setting(.01) | |||
power_t = Setting(.25) | |||
n_iter = Setting(5) | |||
max_iter = Setting(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default in sklearn is 5. Is there a particular reason to have it at 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason. Sklearn will change it to 1000 from 0.21. I decided for 10 only to see if I changed everything correctly (testing widget in Orange).
Orange/widgets/model/owsgd.py
Outdated
@@ -76,7 +76,7 @@ class Outputs(OWBaseLearner.Outputs): | |||
learning_rate_index = Setting(0) | |||
eta0 = Setting(.01) | |||
power_t = Setting(.25) | |||
n_iter = Setting(5) | |||
max_iter = Setting(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement a migrate_settings
method. Without it, old workflows won't use the old n_iter
value as the max_iter
value while their semantics are essentially the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to do it.
Is this correct (added in class OWSGD)?
@classmethod
def migrate_settings(cls, settings_, version):
if version < 2:
settings_["max_iter"] = settings_.get("n_iter", 5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should do the trick. Perhaps delete the setting n_iter
as well to clean up the old settings? You can do this in one line settings_["max_iter"] = settings_.pop("n_iter", 5)
.
Codecov Report
@@ Coverage Diff @@
## master #2920 +/- ##
=========================================
+ Coverage 82.1% 82.1% +<.01%
=========================================
Files 328 328
Lines 56262 56265 +3
=========================================
+ Hits 46194 46198 +4
+ Misses 10068 10067 -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Looks good, just 2 things:
- SGDRegressionLearner should also be fixed in the same way (we have a common widget for both). It is in Orange/regression/linear.py
- We should probably add a control in the widget to set the
tol
parameter. It is not critical for this PR since the previous functionality is still the same. But if you don't add it now, please open an Issue that we should consider adding it before sklearn 0.21 (seems setting tol instead of max_iter will be the preferred way in the fututre).
(Also, the linting and change default back commits should be squashed into the first one at the end)
I'll try to do both ( |
Yes, the SGD widget calls the regression or classification learner depending on the type of data it gets. |
… with sklearn 0.21 changes (tol and max_iter)
It was hard to fall back to the old functionality (of setting just the number of iterations) without being able to set tol to None - I guess that is why you also removed migrate settings? I added a checkbox for |
I'll check it. It is my first PR for Orange so I still have a lot to learn about Orange. |
We really appreciate it! |
Looks ok. I have also tested it locally with different datasets (iris and my datasets). Tested different settings to see if both parameters work. Looks like it works, otherwise I wouldn't get this message |
Thanks everyone. I'm happy to have contributed to Orange. |
Issue
SGDClassificationLearner deprecated parameter (n_iter). Fixes #2917.
Description of changes
Deprecation fix: changed n_iter to max_iter (SGDClassifier)
Includes