Skip to content

Commit 3caf6f0

Browse files
committed
Import upate for sklearn 0.16 and newer
1 parent 7c7c502 commit 3caf6f0

File tree

2 files changed

+66
-34
lines changed

2 files changed

+66
-34
lines changed

ch07/ch07.ipynb

+58-32
Large diffs are not rendered by default.

ch07/ch07.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,15 @@ def ensemble_error(n_classifier, error):
179179

180180

181181

182+
# Scikit-learn 0.16 and newer requires reversing the parent classes
183+
# See https://github.com/rasbt/machine-learning-book/discussions/205 for more details
184+
import sklearn
185+
base_classes = (ClassifierMixin, BaseEstimator) if sklearn.__version__ >= "0.16" else (BaseEstimator, ClassifierMixin)
182186

183-
class MajorityVoteClassifier(BaseEstimator,
184-
ClassifierMixin):
187+
# class MajorityVoteClassifier(BaseEstimator,
188+
# ClassifierMixin):
189+
190+
class MajorityVoteClassifier(*base_classes):
185191
""" A majority vote ensemble classifier
186192
187193
Parameters

0 commit comments

Comments
 (0)