8000 [MRG+1] add docs that C can receive array in RandomizedLogisticRegression by pianomania · Pull Request #6537 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] add docs that C can receive array in RandomizedLogisticRegression #6537

8000
New 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

Merged

Conversation

pianomania
Copy link
Contributor
@pianomania pianomania commented Mar 14, 2016

fix #6525
closes #6536.

@GaelVaroquaux
Copy link
Member

This is PR duplicates #6536, and I'll make the same comment on it.

@amueller
Copy link
Member

Are you still working on this?

@pianomania
Copy link
Contributor Author
pianomania commented Oct 29, 2016

No, but I can keep going if I have free time. What else should I do? Rebase it?

@amueller
Copy link
Member
amueller commented Nov 1, 2016

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."

@pianomania
Copy link
Contributor Author

@amueller I found I have written about the behavior when C is an array in this commit before. Are there some problems?

@amueller
Copy link
Member

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
Copy link
Member

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.

@pianomania pianomania force-pushed the RandomizedLogisticRegression_doc branch from 3535c00 to 7e44df4 Compare February 17, 2017 08:22
@codecov
Copy link
codecov bot commented Feb 17, 2017

Codecov Report

Merging #6537 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #6537      +/-   ##
==========================================
+ Coverage   94.75%   94.75%   +<.01%     
==========================================
  Files         342      342              
  Lines       60801    60813      +12     
==========================================
+ Hits        57609    57621      +12     
  Misses       3192     3192
Impacted Files Coverage Δ
sklearn/linear_model/tests/test_randomized_l1.py 100% <100%> (ø)
sklearn/linear_model/randomized_l1.py 94.76% <100%> (+0.06%)
sklearn/model_selection/tests/test_search.py 99.31% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8694278...da90617. Read the comment docs.

@GaelVaroquaux GaelVaroquaux changed the title [MRG] add docs that C can receive array in RandomizedLogisticRegression [MRG+1] add docs that C can receive array in RandomizedLogisticRegression Feb 17, 2017
@GaelVaroquaux
Copy link
Member

LGTM. +1 for merge.

Copy link
Member
@lesteve lesteve left a 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
Copy link
Member

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)
Copy link
Member
@lesteve lesteve Feb 17, 2017

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.

@GaelVaroquaux
Copy link
Member

By the way: travis is failing. Could you rebase on master to see if this goes away.

@lesteve
Copy link
Member
lesteve commented Feb 17, 2017

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, \
Copy link
Member
@lesteve lesteve Feb 17, 2017

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")

Copy link
Contributor Author

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)
Copy link
Member

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 ...

Copy link
Contributor Author

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."
Copy link
Member

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.

@agramfort agramfort merged commit f952e43 into scikit-learn:master Feb 18, 2017
@agramfort
Copy link
Member

thx @pianomania

sergeyf pushed a commit to sergeyf/scikit-learn that referenced this pull request Feb 28, 2017
…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
@Przemo10 Przemo10 mentioned this pull request Mar 17, 2017
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
…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
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
…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
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
…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
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
…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
lemonlaug pushed a commit to lemonlaug/scikit-learn that referenced this pull request Jan 6, 2021
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C can be an array as well in RandomizedLogisticRegression
5 participants
0