[MRG+1] Make partial_fit ignore n_iter in MiniBatchDictionaryLearning #17433
[MRG+1] Make partial_fit ignore n_iter in MiniBatchDictionaryLearning #17433GaelVaroquaux merged 7 commits intoscikit-learn:masterfrom
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.
- At the end of fit:
self.iter_offset_ = iter_offset + self.n_iterShould this be:
self.iter_offset_ = iter_offset + 1We 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_ == 12I 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! |
GaelVaroquaux
left a comment
There was a problem hiding this comment.
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_ |
thomasjpfan
left a comment
There was a problem hiding this comment.
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.
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.
| 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.
| 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_fitignoren_iterin MiniBatchDictionaryLearning hardcodingn_iter=1indict_learning_onlinecall.