|
6 | 6 |
|
7 | 7 | import numpy as np
|
8 | 8 |
|
9 |
| -from sklearn.base import ClassifierMixin, clone |
| 9 | +from abc import ABCMeta, abstractmethod |
| 10 | +from sklearn.base import ClassifierMixin, MetaEstimatorMixin, clone |
10 | 11 | from sklearn.ensemble import VotingClassifier
|
11 | 12 | from sklearn.ensemble.base import BaseEnsemble, _set_random_states
|
| 13 | +from sklearn.externals import six |
12 | 14 | from sklearn.tree import DecisionTreeClassifier
|
13 | 15 | from sklearn.utils import check_random_state
|
14 | 16 | from sklearn.utils.validation import check_is_fitted
|
15 | 17 |
|
| 18 | + |
16 | 19 | from ..pipeline import Pipeline
|
17 | 20 | from ..under_sampling import RandomUnderSampler
|
18 | 21 |
|
19 |
| -MAX_INT = np.iinfo(np.int32).max |
20 | 22 |
|
| 23 | +class _EasyEnsembleGeneralization(ClassifierMixin, BaseEnsemble): |
21 | 24 |
|
22 |
| -class EasyEnsembleGeneralization(BaseEnsemble, ClassifierMixin): |
23 | 25 | """This classifier generalize the Easy Ensemble algorithm for imbalanced
|
24 | 26 | datasets.
|
25 | 27 |
|
@@ -92,7 +94,7 @@ def __init__(self,
|
92 | 94 |
|
93 | 95 | def _validate_estimator(self):
|
94 | 96 | """Check the estimator and set the base_estimator_ attribute."""
|
95 |
| - super(EasyEnsembleGeneralization, self)._validate_estimator( |
| 97 | + super(_EasyEnsembleGeneralization, self)._validate_estimator( |
96 | 98 | default=DecisionTreeClassifier())
|
97 | 99 |
|
98 | 100 | def _validate_sampler(self):
|
@@ -197,3 +199,11 @@ def predict_proba(self, X):
|
197 | 199 | """
|
198 | 200 | check_is_fitted(self, "_voting")
|
199 | 201 | return self._voting.predict_proba(X)
|
| 202 | + |
| 203 | + |
| 204 | +# XXX make EasyEnsembleGeneralization to pass sklearn compatibility test |
| 205 | +bases = _EasyEnsembleGeneralization.__mro__ |
| 206 | +bases = tuple(x for x in bases if x != MetaEstimatorMixin) |
| 207 | +print(bases) |
| 208 | +EasyEnsembleGeneralization = type( |
| 209 | + 'EasyEnsembleGeneralization', bases, dict(_EasyEnsembleGeneralization.__dict__)) |
0 commit comments