Skip to content

Commit 51df689

Browse files
author
Katrina Ni
committed
some formatting changes, e.g., sort imports
1 parent 2e896dc commit 51df689

5 files changed

+24
-24
lines changed

mlxtend/classifier/ensemble_vote.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
#
99
# License: BSD 3 clause
1010

11-
from sklearn.base import BaseEstimator
12-
from sklearn.base import ClassifierMixin
13-
from sklearn.base import TransformerMixin
14-
from sklearn.preprocessing import LabelEncoder
15-
from sklearn.base import clone
11+
import numpy as np
12+
from sklearn.base import (BaseEstimator, ClassifierMixin, TransformerMixin,
13+
clone)
1614
from sklearn.exceptions import NotFittedError
17-
from ..externals.name_estimators import _name_estimators
15+
from sklearn.preprocessing import LabelEncoder
16+
1817
from ..externals import six
19-
import numpy as np
18+
from ..externals.name_estimators import _name_estimators
2019

2120

2221
class EnsembleVoteClassifier(BaseEstimator, ClassifierMixin, TransformerMixin):
@@ -61,7 +60,7 @@ class EnsembleVoteClassifier(BaseEstimator, ClassifierMixin, TransformerMixin):
6160
fit_base_estimators : bool (default: True)
6261
Refits classifiers in `clfs` if True; uses references to the `clfs`,
6362
otherwise (assumes that the classifiers were already fit).
64-
Note: fit_base_estimators=False will enforce use_clones to be False,
63+
Note: fit_base_estimators=False will enforce use_clones to be False,
6564
and is incompatible to most scikit-learn wrappers!
6665
For instance, if any form of cross-validation is performed
6766
this would require the re-fitting classifiers to training folds, which
@@ -161,6 +160,7 @@ def fit(self, X, y, sample_weight=None):
161160
self.classes_ = self.le_.classes_
162161

163162
if not self.fit_base_estimators:
163+
print('Warning: enforce use_clones to be False')
164164
self.use_clones = False
165165

166166
if self.use_clones:
@@ -283,8 +283,8 @@ def get_params(self, deep=True):
283283
for key, value in six.iteritems(step.get_params(deep=True)):
284284
out['%s__%s' % (name, key)] = value
285285

286-
for key, value in six.iteritems(super(EnsembleVoteClassifier,
287-
self).get_params(deep=False)):
286+
for key, value in six.iteritems(
287+
super(EnsembleVoteClassifier, self).get_params(deep=False)):
288288
out['%s' % key] = value
289289
return out
290290

mlxtend/classifier/stacking_classification.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#
99
# License: BSD 3 clause
1010

11+
import numpy as np
12+
from scipy import sparse
13+
from sklearn.base import TransformerMixin, clone
14+
1115
from ..externals.estimator_checks import check_is_fitted
1216
from ..externals.name_estimators import _name_estimators
1317
from ..utils.base_compostion import _BaseXComposition
1418
from ._base_classification import _BaseStackingClassifier
15-
from scipy import sparse
16-
from sklearn.base import TransformerMixin
17-
from sklearn.base import clone
18-
import numpy as np
1919

2020

2121
class StackingClassifier(_BaseXComposition, _BaseStackingClassifier,

mlxtend/classifier/stacking_cv_classification.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
#
1010
# License: BSD 3 clause
1111

12-
from ..externals.name_estimators import _name_estimators
13-
from ..externals.estimator_checks import check_is_fitted
14-
from ..utils.base_compostion import _BaseXComposition
15-
from ._base_classification import _BaseStackingClassifier
1612
import numpy as np
1713
from scipy import sparse
18-
from sklearn.base import TransformerMixin
19-
from sklearn.base import clone
14+
from sklearn.base import TransformerMixin, clone
2015
from sklearn.model_selection import cross_val_predict
2116
from sklearn.model_selection._split import check_cv
17+
18+
from ..externals.estimator_checks import check_is_fitted
19+
from ..externals.name_estimators import _name_estimators
20+
from ..utils.base_compostion import _BaseXComposition
21+
from ._base_classification import _BaseStackingClassifier
22+
2223
# from sklearn.utils import check_X_y
2324

2425

mlxtend/classifier/tests/test_stacking_classifier.py

-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ def test_not_fitted():
328328
clf2 = GaussianNB()
329329
sclf = StackingClassifier(classifiers=[clf1, clf2],
330330
use_probas=True,
331-
use_clones=True,
332331
meta_classifier=meta)
333332

334333
X, _ = iris_data()

mlxtend/classifier/tests/test_stacking_cv_classifier.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ def test_meta_feat_reordering():
448448
shuffle=True,
449449
random_state=42,
450450
store_train_meta_features=True)
451-
X_train, X_test, y_train, y_test = train_test_split(X_breast, y_breast,
452-
random_state=0,
453-
test_size=0.3)
451+
X_train, _, y_train, _ = train_test_split(X_breast, y_breast,
452+
random_state=0,
453+
test_size=0.3)
454454
stclf.fit(X_train, y_train)
455455

456456
if Version(sklearn_version) < Version("0.21"):

0 commit comments

Comments
 (0)