-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the convention has been to write "Returns" There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 coefficient R^2 is defined as (1 - u/v), where u is the residual | ||||||
sum of squares ((y_true - y_pred) ** 2).sum() and v is the total | ||||||
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe say "dict of keyword arguments" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Fit parameters. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
X_new : numpy array of shape [n_samples, n_features_new] | ||||||
Transformed array. | ||||||
|
||||||
""" | ||||||
# non-optimized default implementation; override when a better | ||||||
# method is possible for a given clustering algorithm | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -328,7 +328,7 @@ class VotingRegressor(RegressorMixin, _BaseVoting): | |||||
|
||||||
Parameters | ||||||
---------- | ||||||
estimators : list of (string, estimator) tuples | ||||||
estimators : list of (str, estimator) tuples | ||||||
Invoking the ``fit`` method on the ``VotingRegressor`` will fit clones | ||||||
of those original estimators that will be stored in the class attribute | ||||||
``self.estimators_``. An estimator can be set to ``'drop'`` using | ||||||
|
@@ -359,6 +359,10 @@ class VotingRegressor(RegressorMixin, _BaseVoting): | |||||
|
||||||
.. versionadded:: 0.20 | ||||||
|
||||||
See Also | ||||||
-------- | ||||||
VotingClassifier: Soft Voting/Majority Rule classifier. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
>>> import numpy as np | ||||||
|
@@ -372,10 +376,6 @@ class VotingRegressor(RegressorMixin, _BaseVoting): | |||||
>>> er = VotingRegressor([('lr', r1), ('rf', r2)]) | ||||||
>>> print(er.fit(X, y).predict(X)) | ||||||
[ 3.3 5.7 11.8 19.7 28. 40.3] | ||||||
|
||||||
See also | ||||||
-------- | ||||||
VotingClassifier: Soft Voting/Majority Rule classifier. | ||||||
""" | ||||||
|
||||||
def __init__(self, estimators, weights=None, n_jobs=None): | ||||||
|
@@ -384,7 +384,7 @@ def __init__(self, estimators, weights=None, n_jobs=None): | |||||
self.n_jobs = n_jobs | ||||||
|
||||||
def fit(self, X, y, sample_weight=None): | ||||||
""" Fit the estimators. | ||||||
"""Fit the estimators. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
|
@@ -403,6 +403,7 @@ def fit(self, X, y, sample_weight=None): | |||||
Returns | ||||||
------- | ||||||
self : object | ||||||
Returns self. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
although I agree that it's probably not very useful in any case. |
||||||
""" | ||||||
y = column_or_1d(y, warn=True) | ||||||
return super().fit(X, y, sample_weight) | ||||||
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no actually this should be,
(with the right indentation) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity, why should this be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, it can only return an |
||||||
values predicted by each regressor. | ||||||
""" | ||||||
check_is_fitted(self) | ||||||
|
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 am unfamiliar with this
$
notation. I see it above forLogisticRegression$
and not below forKernelDensity
. What does it mean and what made you decide to put$
?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.
It means end of the string with regular expression. LogisticRegression without
$
would match any of its methods, not just the main docstring