Repository navigation
BUG: rename wts to weights issue #4725 - #5762
Conversation
|
Hello @zveryansky! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-05-21 12:39:19 UTC |
Codecov Report
@@ Coverage Diff @@
## master #5762 +/- ##
=========================================
+ Coverage 82.28% 82.3% +0.01%
=========================================
Files 593 593
Lines 93622 93627 +5
Branches 10339 10333 -6
=========================================
+ Hits 77041 77057 +16
+ Misses 14184 14177 -7
+ Partials 2397 2393 -4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #5762 +/- ##
=========================================
+ Coverage 82.28% 82.3% +0.01%
=========================================
Files 593 593
Lines 93622 93627 +5
Branches 10339 10333 -6
=========================================
+ Hits 77041 77057 +16
+ Misses 14184 14178 -6
+ Partials 2397 2392 -5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #5762 +/- ##
=========================================
+ Coverage 82.28% 82.3% +0.01%
=========================================
Files 593 593
Lines 93622 93648 +26
Branches 10339 10339
=========================================
+ Hits 77041 77074 +33
+ Misses 14184 14180 -4
+ Partials 2397 2394 -3
Continue to review full report at Codecov.
|
| """ | ||
|
|
||
| def __init__(self, penalty, weights=None, restriction=None): | ||
| def __init__(self, penalty, weights=1., restriction=None): |
There was a problem hiding this comment.
I really think it would be better to leave weights=None for the default and then below use
self.weights = weights if weights is not None else 1.
Same comment for other changes like this.
Then you can leave the doc string type for weight as ndarray, optional
There was a problem hiding this comment.
- it is a misleading practice to use
Noneas a default but always change it to1.0If it always changed to 1.0 it should be 1.0 by default. - as a user I couldn't understand the behavior of
weights=Nonewithout looking into the code. It could be changed to 0.0,1.0,anystatisticsyouimagine under the hood and I now nothing about it without sources. Explicit is better than implicit. - Leaving
weights=Nonerequired for this code to workweights = weights if weights is not None else wtsbut this approach leads us to the point where user could just addweightsargument and not removewtsand we will pickweightsand not force user to actually replace a deprecated argument.
@josef-pkt
|
What's the reason for these changes? AFAICS, the old code is just as intended, i.e. it currently uses |
|
Using None for default values is pretty standard. You don’t have to look
at code since the docstring explains what the default value is.
This said, your pattern is actually used, see
https://www.statsmodels.org/stable/generated/statsmodels.regression.linear_model.WLS.html
And so there is precedent not for this. Given WLS I’m inclined to think
weights=1. Is ok, although the docstring needs to match WLS for type, e.g.,
ndarray, optional and should not say 1..
What I don’t like about 1. Is tha most estimators are the same for 2. Or
3.1415, since weights are often normalized internally to be a unit vector.
…On Tue, 21 May 2019 at 06:20 Alex ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In statsmodels/base/_penalties.py
<#5762 (comment)>
:
> @@ -459,13 +444,10 @@ class ConstraintsPenalty(object):
"""
- def __init__(self, penalty, weights=None, restriction=None):
+ def __init__(self, penalty, weights=1., restriction=None):
1. it is a misleading practice to use None as a default but always
change it to 1.0 If it always changed to 1.0 it should be 1.0 by
default.
2. as a user I couldn't understand the behavior of weights=None
without looking into the code. It could be changed to
0.0,1.0,anystatisticsyouimagine under the hood and I now nothing about it
without sources. Explicit is better than implicit.
3. Leaving weights=None required for this code to work weights =
weights if weights is not None else wts but this approach leads us to
the point where user could just add weights argument and not remove wts
and we will pick weights and not force user to actually replace a
deprecated argument.
@josef-pkt <https://github.com/josef-pkt>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5762?email_source=notifications&email_token=ABKTSROZ32LEMF6LGGSUVY3PWOBAJA5CNFSM4HOEY35KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBZFYDOI#discussion_r285854587>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKTSRJ5QWNCKG2OLHWLYHDPWOBAJANCNFSM4HOEY35A>
.
|
|
The purpose of None here is mainly for the deprecation of I think in general, the default for weights None or 1. is still unclear. GLM uses None The difference to WLS is that WLS is designed for weights, weights are an integral part of WLS. |
|
This looks pretty good now. Minimal change to get things working and tests. |
|
looks very good to me, Thanks aside: GAM does not have (verified) support for weights yet, and some of the weight usages are still unclear, but that most likely will not directly affect the penalty classes |
|
Thanks for the PR. |
NumPy's guide.
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels.