Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] Apply numpydoc validation to VotingRegressor methods #15500

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

Conversation

Tiffany8
Copy link
Contributor

@Tiffany8 Tiffany8 commented Nov 2, 2019

Reference Issues/PRs

Addresses ##15440.

What does this implement/fix? Explain your changes.

Applied numpydoc validation to the estimator VotingRegressor and a some of the methods and added them to the docstring test whitelist

  • fit
  • transform
  • predict
  • score

Specifically, changes included:

  • adding missing return doc
  • properly capitalizing section names
  • removing whitespaces surrounding docstring text
  • starting summary with infinitive verb (as opposed to third person)
  • documenting undocumented parameters
  • properly ordering sections
  • eliminating blank lines at the end of docstring

Any other comments?

@Tiffany8 Tiffany8 changed the title Apply numpydoc validation to VotingRegressor methods [WIP] Apply numpydoc validation to VotingRegressor methods Nov 2, 2019
…otingregressor-docstrings

# Conflicts:
#	maint_tools/test_docstrings.py
@Tiffany8 Tiffany8 changed the title [WIP] Apply numpydoc validation to VotingRegressor methods [MRG] Apply numpydoc validation to VotingRegressor methods Nov 2, 2019
@@ -23,6 +23,11 @@
"RidgeClassifier.fit",
"RidgeClassifierCV.decision_function",
"SGDClassifier.decision_function",
"VotingRegressor$",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unfamiliar with this $ notation. I see it above for LogisticRegression$ and not below for KernelDensity. What does it mean and what made you decide to put $?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means end of the string with regular expression. LogisticRegression without $ would match any of its methods, not just the main docstring

@@ -369,7 +369,7 @@ class RegressorMixin:
_estimator_type = "regressor"

def score(self, X, y, sample_weight=None):
"""Returns the coefficient of determination R^2 of the prediction.
"""Return the coefficient of determination R^2 of the prediction.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the convention has been to write "Returns"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is okay since we follow https://www.python.org/dev/peps/pep-0257/

The docstring is a phrase ending in a period. It prescribes the function or method's effect as a command ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...".

@@ -549,11 +549,13 @@ def fit_transform(self, X, y=None, **fit_params):
y : numpy array of shape [n_samples]
Target values.

**fit_params : Any number of parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say "dict of keyword arguments"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**fit_params : Any number of parameters
**fit_params : dict

@eickenberg
Copy link
Contributor

Apart from the comments looks good to me pending CI

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Tiffany8 ! A few comments below

@@ -403,6 +403,7 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns self.
Fitted estimator.

although I agree that it's probably not very useful in any case.

@@ -438,7 +439,7 @@ def transform(self, X):
Returns
-------
predictions
array-like of shape (n_samples, n_classifiers), being
Array-like of shape (n_samples, n_classifiers), being
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no actually this should be,

predictions : array-like of shape (n_samples, n_classifiers)
    Values predicted by each regressor.

(with the right indentation)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, why should this be an array-like instead of an array. Can it output anything other than ndarrays? (My only guess would be that if a dataframe was input it could output one and that dfs fall under the array-like definition, but haven't followed in detail the inclusion of dfs as possible inputs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it can only return an array. We use array-like for input dtypes, and it was probably copy-pasted there...

@cmarmo
Copy link
Contributor

cmarmo commented Nov 12, 2019

@Tiffany8, do you think you could find some time to synchronize to upstream and address the comments? Thanks!

@reshamas
Copy link
Member

@rth is it possible to remove the "Needs work" label from this merged PR? thanks.

@rth rth removed the Needs work label Dec 26, 2019
@rth
Copy link
Member

rth commented Dec 26, 2019

Sure, done. It wasn't merged but closed BTW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants