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

Skip to content

[MRG] DOC: Use setattr(self, ...) instead of self.setattr(...) in rolling your own estimator section #9866

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
merged 1 commit into from
Oct 3, 2017

Conversation

jschendel
Copy link
Contributor

What does this implement/fix? Explain your changes.

The current example interface for set_params here is:

def set_params(self, **parameters):
    for parameter, value in parameters.items():
        self.setattr(parameter, value)
    return self

I don't think that self.setattr is valid. It doesn't look like BaseEstimator or the mixins have a self.setattr, and it isn't mentioned earlier in the documentation. I can't find any references to self.setattr in the codebase either (unless self.__setattr__ is what's meant).

Using the Python built-in setattr appears to be more common, so I propose changing to:

def set_params(self, **parameters):
    for parameter, value in parameters.items():
        setattr(self, parameter, value)
    return self

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Thanks

@TomDLT TomDLT merged commit 12cf7db into scikit-learn:master Oct 3, 2017
@TomDLT
Copy link
Member

TomDLT commented Oct 3, 2017

Thanks @jschendel

@jschendel jschendel deleted the doc-contrib-setattr branch October 3, 2017 23:39
amueller pushed a commit to jnothman/scikit-learn that referenced this pull request Oct 20, 2017
yarikoptic added a commit to yarikoptic/scikit-learn that referenced this pull request Oct 24, 2017
* tag '0.19.1': (117 commits)
  TST Improve SelectFromModel tests (scikit-learn#9733)
  Name in what's new
  [MRG+1] Raise error when SparseSeries is passed into classification metrics (scikit-learn#7373)
  Fix LogisticRegressionCV default solver value in docstring (scikit-learn#9962)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  DOC fix a typo (scikit-learn#9892)
  [MRG+1] Ledoit-Wolf behavior explanation (scikit-learn#9500)
  [MRG+1] Fix typos in documentation (scikit-learn#9878)
  DOC: Use setattr(self, ...) instead of self.setattr(...) (scikit-learn#9866)
  DOC Removed a duplicate occurrence of a word in 'sklearn.neighbors.KNeighborsRegressor' docs (scikit-learn#9862)
  FIX docstring of negative_outlier_factor_ in LOF (scikit-learn#9809)
  [MRG+1] Fix scikit-learn#9743: Adding parameter information to docstring. (scikit-learn#9757)
  DOC: fix docstring of Imputer.fit (scikit-learn#9769)
  various minor spelling tweaks (scikit-learn#9783)
  MAINT comment on apparent inconsistency
  [MRG+1] DOC fix headers level in cross_validation.rst (scikit-learn#9679)
  Fix mailmap format (scikit-learn#9620)
  DOC Fix typos (scikit-learn#9577)
  Typo (scikit-learn#9571)
  ...
yarikoptic added a commit to yarikoptic/scikit-learn that referenced this pull request Oct 24, 2017
* releases: (117 commits)
  TST Improve SelectFromModel tests (scikit-learn#9733)
  Name in what's new
  [MRG+1] Raise error when SparseSeries is passed into classification metrics (scikit-learn#7373)
  Fix LogisticRegressionCV default solver value in docstring (scikit-learn#9962)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  DOC fix a typo (scikit-learn#9892)
  [MRG+1] Ledoit-Wolf behavior explanation (scikit-learn#9500)
  [MRG+1] Fix typos in documentation (scikit-learn#9878)
  DOC: Use setattr(self, ...) instead of self.setattr(...) (scikit-learn#9866)
  DOC Removed a duplicate occurrence of a word in 'sklearn.neighbors.KNeighborsRegressor' docs (scikit-learn#9862)
  FIX docstring of negative_outlier_factor_ in LOF (scikit-learn#9809)
  [MRG+1] Fix scikit-learn#9743: Adding parameter information to docstring. (scikit-learn#9757)
  DOC: fix docstring of Imputer.fit (scikit-learn#9769)
  various minor spelling tweaks (scikit-learn#9783)
  MAINT comment on apparent inconsistency
  [MRG+1] DOC fix headers level in cross_validation.rst (scikit-learn#9679)
  Fix mailmap format (scikit-learn#9620)
  DOC Fix typos (scikit-learn#9577)
  Typo (scikit-learn#9571)
  ...
yarikoptic added a commit to yarikoptic/scikit-learn that referenced this pull request Oct 24, 2017
* dfsg: (117 commits)
  TST Improve SelectFromModel tests (scikit-learn#9733)
  Name in what's new
  [MRG+1] Raise error when SparseSeries is passed into classification metrics (scikit-learn#7373)
  Fix LogisticRegressionCV default solver value in docstring (scikit-learn#9962)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  [MRG+1] DOC fix sign in GBRT mathematical formulation (scikit-learn#9885)
  DOC fix a typo (scikit-learn#9892)
  [MRG+1] Ledoit-Wolf behavior explanation (scikit-learn#9500)
  [MRG+1] Fix typos in documentation (scikit-learn#9878)
  DOC: Use setattr(self, ...) instead of self.setattr(...) (scikit-learn#9866)
  DOC Removed a duplicate occurrence of a word in 'sklearn.neighbors.KNeighborsRegressor' docs (scikit-learn#9862)
  FIX docstring of negative_outlier_factor_ in LOF (scikit-learn#9809)
  [MRG+1] Fix scikit-learn#9743: Adding parameter information to docstring. (scikit-learn#9757)
  DOC: fix docstring of Imputer.fit (scikit-learn#9769)
  various minor spelling tweaks (scikit-learn#9783)
  MAINT comment on apparent inconsistency
  [MRG+1] DOC fix headers level in cross_validation.rst (scikit-learn#9679)
  Fix mailmap format (scikit-learn#9620)
  DOC Fix typos (scikit-learn#9577)
  Typo (scikit-learn#9571)
  ...
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
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.

3 participants