-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] add docs that C can receive array in RandomizedLogisticRegression #6537
8000New 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] add docs that C can receive array in RandomizedLogisticRegression #6537
Conversation
This is PR duplicates #6536, and I'll make the same comment on it. |
Are you still working on this? |
No, but I can keep going if I have free time. What else should I do? Rebase it? |
What @GaelVaroquaux said in the other PR: "You should indica 8000 te the behavior when C is an array: what are the different values of the array used for." |
@amueller I found I have written about the behavior when C is an array in this commit before. Are there some problems? |
Oh sorry I somehow overlooked that. @GaelVaroquaux good? |
The regularization parameter C in the LogisticRegression. | ||
When C is an array, fit will take each regularization parameter in C | ||
one by one for LogisticRegression and store results for each one | ||
in all_scores_, where columns and rows represent corresponding |
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.
can you please use double backticks around all_scores_
? Not only is it a variable, the documentation generation breaks if something ends with an underscore and is not escaped.
3535c00
to
7e44df4
Compare
Codecov Report
@@ Coverage Diff @@
## master #6537 +/- ##
==========================================
+ Coverage 94.75% 94.75% +<.01%
==========================================
Files 342 342
Lines 60801 60813 +12
==========================================
+ Hits 57609 57621 +12
Misses 3192 3192
Continue to review full report at Codecov.
|
LGTM. +1 for merge. |
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.
There is a flake8 problem to fix. Other than that minor comments
@@ -381,8 +384,12 @@ class RandomizedLogisticRegression(BaseRandomizedLinearModel): | |||
|
|||
Parameters | |||
---------- | |||
C : float, optional, default=1 | |||
C : float or array of shape [n_reg_parameter], optional, default=1 |
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.
array-like rather than array
@@ -354,6 +354,9 @@ def _randomized_logistic(X, y, weights, mask, C=1., verbose=False, | |||
X *= (1 - weights) | |||
|
|||
C = np.atleast_1d(np.asarray(C, dtype=np.float64)) | |||
if C.ndim > 1: | |||
raise ValueError("C should be 1-dim array, but got %d-dim array instead." % C.ndim) |
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.
1-dimensional or 1d rather than 1-dim. Same comment about %d-dim.
By the way: travis is failing. Could you rebase on master to see if this goes away. |
That's a flake8 issue that needs fixing. |
@@ -355,7 +355,8 @@ def _randomized_logistic(X, y, weights, mask, C=1., verbose=False, | |||
|
|||
C = np.atleast_1d(np.asarray(C, dtype=np.float64)) | |||
if C.ndim > 1: | |||
raise ValueError("C should be 1-dim array, but got %d-dim array instead." % C.ndim) | |||
raise ValueError("C should be 1-dim array, \ |
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.
If you decided to go for 1-dimensional use it everywhere (and that's a s and not a t in dimensional), i.e. "should be a 1-dimensional array" and "but got a %d-dimensional array".
Also you don't need the backslash:
raise ValueError("beginning of the string "
"that continues still here and with a format: {}".format("insert this")
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.
sorry for that typo
@@ -354,6 +354,10 @@ def _randomized_logistic(X, y, weights, mask, C=1., verbose=False, | |||
X *= (1 - weights) | |||
|
|||
C = np.atleast_1d(np.asarray(C, dtype=np.float64)) | |||
if C.ndim > 1: | |||
raise ValueError("C should be 1-dimensional array, " | |||
"but got %d-dimensional array instead." % C.ndim) |
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.
I forgot: it is always good to show the parameter that you got because it gives an additional hint to the user what he needs to change.
So something like this (add the "a" that were missed from my previous comment):
raise ValueError("C should be a 1-dimensional array-like, "
"but got a {}-dimensional array-like instead: {}".format(C.ndim, C))
It would be great to add a test for this error message by the way ...
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.
OK, I will add a test!
@@ -354,6 +354,11 @@ def _randomized_logistic(X, y, weights, mask, C=1., verbose=False, | |||
X *= (1 - weights) | |||
|
|||
C = np.atleast_1d(np.asarray(C, dtype=np.float64)) | |||
if C.ndim > 1: | |||
raise ValueError("C should be 1-dimensional array, " | |||
"but got a %d-dimensional array instead: %d." |
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 is going to give an error because "%d"
is not a valid format for an array ... this is why we need a test.
Please use .format
rather than %
(less chance of making silly mistakes like this). Also please use "array-like" and not "array" as mentioned in one of my previous comment.
thx @pianomania |
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
…sion (scikit-learn#6537) * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * doc: state that parameter C can receive an array * add more details in doc, and check the dim of C * a little modification * minor modifications and make line length less than 79 characters * remove the backslash and correct typos * meet PEP8's E128 requirement * use .format and add a test
fix #6525
closes #6536.