[MRG] FIX: Allow coef_=None with warm_start=True in MultiTaskElasticNet#12844
[MRG] FIX: Allow coef_=None with warm_start=True in MultiTaskElasticNet#12844larsoner wants to merge 1 commit intoscikit-learn:masterfrom
Conversation
|
LGTM |
|
Just for my own understanding, when does it makes sense to want warm-starting while having no coefficients to start with? |
|
@NicolasHug IIUC it's just a convenience thing at our end that we can always have |
|
... by "our function" I mean in a function we have in another library (MNE), and callers of that function don't need to care about |
|
Ok thanks. So I guess my question becomes: how can If your use-case is 'we allow our users to set |
In the latest In
No our use case is to repeat instantiation + fit steps, supplying a properly shaped |
That seems to be legacy code from times when setting attributes in but this is not the case anymore. Would need input from core devs. @amueller maybe? EDIT:
So you're still doing something like |
|
I don't see why we should support this. This is not in line with any standard contracts in sklearn. If you want to do this, I feel it's up to you (MNE) to ensure something sensible happens. |
This restores the ability to have
clf.coef_ = Noneduring fitting withclf = MultiTaskElasticNet(..., warm_start=True). Code that currently works with the latest release started emitting this error when running onsklearnmaster (now shown with the error in the test suite when the changes tocoordinate_descent.pyare omitted):One potential alternative is that I could in my code set
warm_start=Falseif the user suppliescoef_ = None, rather than always passingwarm_start=True. Feel free to close if that's the preferred way, though it's possible other people might also get hit by this problem if they also relied onwarm_start=Truefollowed byclf.coef_ = Noneworking.Just modified an existing test to avoid adding to test time, but can split it off if it seems worthwhile.