-
-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
[MRG+1] Make partial_fit ignore n_iter in MiniBatchDictionaryLearning #17433
Conversation
@GaelVaroquaux , do you mind to have a look? I'm in the process of familiarizing with online algorithms. Thanks! |
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.
- At the end of fit:
self.iter_offset_ = iter_offset + self.n_iter
Should this be:
self.iter_offset_ = iter_offset + 1
We would need test to make sure iter_offset_
is updated correctly.
- It is strange that
n_iter_
is not getting updated inpartial_fit
(or created on the first call topartial_fit
.
Definitely! Thanks! |
My understanding was that |
I'm concerned with multiple calls to est = MiniBatchDictionaryLearning(n_iter=10)
est.fit(...)
est.partial_fit(...) # one iter
est.partial_fit(...) # one iter
# Should this be true?
assert est.n_iter_ == 12 I am not familiar enough with design to know the intention with |
Neither am I... :D
But the reason of this is unclear to me. Maybe @vene could help? :) Thanks! |
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.
This seems to me like the good fix, and a good test. Thanks a lot!!
Maybe this warrants a small note in the whats_new. Otherwise, it's good to go. This will be useful!
for sample in X: | ||
dictV_pfit = dict2.partial_fit(sample[np.newaxis, :]) | ||
|
||
assert dictV_fit.iter_offset_ == dictV_pfit.iter_offset_ |
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.
Good test!!
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.
Minor commits, otherwise LGTM
dict2 = MiniBatchDictionaryLearning(n_components, n_iter=10, | ||
dict_init=V, random_state=0, | ||
shuffle=False) | ||
dictV_fit = dict1.fit(X) |
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.
To reduce the number of variables in the test
dictV_fit = dict1.fit(X) | |
dict1.fit(X) |
shuffle=False) | ||
dictV_fit = dict1.fit(X) | ||
for sample in X: | ||
dictV_pfit = dict2.partial_fit(sample[np.newaxis, :]) |
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.
dictV_pfit = dict2.partial_fit(sample[np.newaxis, :]) | |
dict2.partial_fit(sample[np.newaxis, :]) |
for sample in X: | ||
dictV_pfit = dict2.partial_fit(sample[np.newaxis, :]) | ||
|
||
assert dictV_fit.iter_offset_ == dictV_pfit.iter_offset_ |
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.
assert dictV_fit.iter_offset_ == dictV_pfit.iter_offset_ | |
assert dict1.iter_offset_ == dict2.iter_offset_ |
Two +1s, green CI. Merging. Thanks @cmarmo ! |
…scikit-learn#17433) * Make partial_fit ignore n_iter. * Revert whiteline. * Fix self.iter_offset. * Add test on iter_offset_ * Add what's new entry * Apply thomasjpfan suggestions.
…scikit-learn#17433) * Make partial_fit ignore n_iter. * Revert whiteline. * Fix self.iter_offset. * Add test on iter_offset_ * Add what's new entry * Apply thomasjpfan suggestions.
…scikit-learn#17433) * Make partial_fit ignore n_iter. * Revert whiteline. * Fix self.iter_offset. * Add test on iter_offset_ * Add what's new entry * Apply thomasjpfan suggestions.
Reference Issues/PRs
Fixes #6779
What does this implement/fix? Explain your changes.
Makes
partial_fit
ignoren_iter
in MiniBatchDictionaryLearning hardcodingn_iter=1
indict_learning_online
call.