[MRG+1] Fix broken L1 deprecations and svm scale C example.#4261
[MRG+1] Fix broken L1 deprecations and svm scale C example.#4261ogrisel merged 6 commits intoscikit-learn:masterfrom
L1 deprecations and svm scale C example.#4261Conversation
In my experience, it is a bad idea to introduce too much flexibility: |
|
Ah makes sense! thanks for clarifying :) |
examples/svm/plot_svm_scale_c.py
Outdated
There was a problem hiding this comment.
It should be squared_hinge, instead of ssquared_hinge, no?
There was a problem hiding this comment.
Ah! I did this to test the first commit and forgot to change it back ;)
1ae37dd to
3a8eae0
Compare
|
This example use to work in scikit-learn 0.15.2: http://scikit-learn.org/stable/auto_examples/svm/plot_svm_scale_c.html This means that this change introduced without preserving backward compatibility. We need to add support for the old notation while raising informative deprecation warning messages such as:
|
|
Furthermore this API change should be documented in whats new: http://scikit-learn.org/dev/whats_new.html#api-changes-summary |
|
'l2' is still supported... and does display that deprecation warning!! ( the problem was with the Also see #3933 ... |
|
This change of behavior might have been introduced by the integration of the new If that the case we need to check that the |
|
Oh! okay! will find out what caused the change and deprecate it properly :) |
|
By reading the diff of https://github.com/scikit-learn/scikit-learn/pull/3933/files , the code used to be case insensitive, which is no longer the case. +1 for deprecating explicitly the upper case notation for the l1 and l2 penalties and losses. |
|
LGTM apart from @ogrisel comment on tighter testing and the typo that gives the travis error ;) |
776af2d to
a28dba9
Compare
sklearn/svm/classes.py
Outdated
There was a problem hiding this comment.
Please also add backward compat for penalty in ('L1', 'L2') (uppercase) that maps to the l1 or l2 (lowercase) with a similar deprecation warning.
There was a problem hiding this comment.
And add deprecation warning tests for those. Please git grep "assert_warns_message(DeprecationWarning" to find examples on how to write such tests.
There was a problem hiding this comment.
woops I clicked on the edit button instead of the reply button and deleted part of your reply by mistake... Sorry for that.
Anyway I wanted to also let you know that you can drop the nested parens in the above call to warnings.warn.
There was a problem hiding this comment.
Oh! thats good to know! thanks... I keep doing that a lot! ;)
sklearn/svm/base.py
Outdated
There was a problem hiding this comment.
We need to provide explicit and informative warning and error messages that recall the values of both the observed and expected values. In this case:
if loss in ('L1', 'L2'):
warnings.warn("loss='%s' has been deprecated in favor of loss='%s' as of 0.16. "
"Backward compatibility for the uppercase notation will be removed"
" in 0.18." % (loss, loss.lower()))and a similar message for penalty.
We should not assume that the user has the source code at hand with the precise line where this class is instantiated when executing a program that causes this message to be raised. Putting explicit parameter values in the message is likely to help him / her find the source of the problem much more quickly.
There was a problem hiding this comment.
done ;)
This is not addressed in the last commit currently visible on github (635b933). Travis is still broken at this point.
There was a problem hiding this comment.
Ah :/ Sorry!! I'll fix this soon... ( I must have forgotten to push I guess )
01143b7 to
a878fac
Compare
|
@ogrisel could you please take a look at this now? Have added the tests and done deprecations as follows -
|
|
You can't deprecate inside an |
|
Tests still failing btw. |
a878fac to
3429357
Compare
8e055a8 to
802e5b4
Compare
|
done! please take a look now :) |
sklearn/svm/base.py
Outdated
There was a problem hiding this comment.
Perhaps the old one was more readable?
There was a problem hiding this comment.
You mean the formatting of the nested dict? I agree I preferred the old formatting.
There was a problem hiding this comment.
Yea :) thanks will revert that!
|
Apart from this last cosmetic comment, +1 on my side. |
802e5b4 to
6d222fd
Compare
|
Ok merging this! |
[MRG+1] Broken svm scale C example
|
Thanks again @ragv! |
L1 deprecations and svm scale C example.
fixes #4260
@ogrisel Please take a look...
loss, penalty-->penalty, lossin error messagelossandpenaltyare passed.L1( upper case )