Skip to content

Commit

Permalink
[MRG] DOC solve rendering set_params in Voting and Stacking (#15074)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre authored and jeremiedbb committed Sep 24, 2019
1 parent 93c628e commit 6ea1873
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions sklearn/ensemble/_stacking.py
Expand Up @@ -80,11 +80,17 @@ def set_params(self, **params):
Examples
--------
# In this example, the RandomForestClassifier is removed
clf1 = LogisticRegression()
clf2 = RandomForestClassifier()
eclf = StackingClassifier(estimators=[('lr', clf1), ('rf', clf2)]
eclf.set_params(rf='drop')
In this example, the RandomForestClassifier is removed.
>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.ensemble import VotingClassifier
>>> clf1 = LogisticRegression()
>>> clf2 = RandomForestClassifier()
>>> eclf = StackingClassifier(estimators=[('lr', clf1), ('rf', clf2)])
>>> eclf.set_params(rf='drop')
StackingClassifier(estimators=[('lr', LogisticRegression()),
('rf', 'drop')])
"""
super()._set_params('estimators', **params)
return self
Expand Down
16 changes: 11 additions & 5 deletions sklearn/ensemble/voting.py
Expand Up @@ -109,11 +109,17 @@ def set_params(self, **params):
Examples
--------
# In this example, the RandomForestClassifier is removed
clf1 = LogisticRegression()
clf2 = RandomForestClassifier()
eclf = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2)]
eclf.set_params(rf=None)
In this example, the RandomForestClassifier is removed.
>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.ensemble import VotingClassifier
>>> clf1 = LogisticRegression()
>>> clf2 = RandomForestClassifier()
>>> eclf = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2)])
>>> eclf.set_params(rf=None)
VotingClassifier(estimators=[('lr', LogisticRegression()),
('rf', None)])
"""
return self._set_params('estimators', **params)

Expand Down

0 comments on commit 6ea1873

Please sign in to comment.