Skip to content
Snippets Groups Projects
Commit a453e239 authored by Dominique Benielli's avatar Dominique Benielli
Browse files

Update mumbo.py

parent f0ff1a72
Branches
Tags
No related merge requests found
Pipeline #11883 failed
...@@ -53,9 +53,7 @@ from sklearn.ensemble._forest import BaseForest ...@@ -53,9 +53,7 @@ from sklearn.ensemble._forest import BaseForest
from sklearn.metrics import accuracy_score from sklearn.metrics import accuracy_score
from sklearn.tree import DecisionTreeClassifier from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import BaseDecisionTree from sklearn.tree import BaseDecisionTree
from sklearn.tree._tree import DTYPE ValueError: cannot resize an array that references or is referenced from sklearn.tree._tree import DTYPE
951E by another array in this way.
952E Use the np.resize function or refcheck=False
from sklearn.utils import check_array, check_X_y, check_random_state from sklearn.utils import check_array, check_X_y, check_random_state
from sklearn.utils.multiclass import check_classification_targets from sklearn.utils.multiclass import check_classification_targets
from sklearn.utils.validation import check_is_fitted, has_fit_parameter from sklearn.utils.validation import check_is_fitted, has_fit_parameter
...@@ -68,9 +66,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -68,9 +66,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
classifiers focus more on difficult cases. classifiers focus more on difficult cases.
A MuMBo classifier. A MuMBo classifier.
A MuMBo classifier is a meta-estimator that implements a multimodal ValueError: cannot resize an array that references or is referenced A MuMBo classifier is a meta-estimator that implements a multimodal
951E by another array in this way.
952E Use the np.resize function or refcheck=False
(or multi-view) boosting algorithm: (or multi-view) boosting algorithm:
It fits a set of classifiers on the original dataset splitted into several It fits a set of classifiers on the original dataset splitted into several
...@@ -83,9 +79,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -83,9 +79,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
base_estimator : object, optional (default=DecisionTreeClassifier) base_estimator : object, optional (default=DecisionTreeClassifier)
Base estimator from which the boosted ensemble is built. Base estimator from which the boosted ensemble is built.
Support for sample weighting is required, as well as proper `classes_` Support for sample weighting is required, as well as proper `classes_`
and `n_classes_` attributes. The default is a DecisionTreeClassifie ValueError: cannot resize an array that references or is referenced and `n_classes_` attributes. The default is a DecisionTreeClassifie
951E by another array in this way.
952E Use the np.resize function or refcheck=Falser
with parameter ``max_depth=1``. with parameter ``max_depth=1``.
n_estimators : integer, optional (default=50) n_estimators : integer, optional (default=50)
...@@ -116,9 +110,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -116,9 +110,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
n_classes\_ : int n_classes\_ : int
Number of classes. Number of classes.
estimator_weights\_ : numpy.ndarray of floats, shape = (len(estimators\ ValueError: cannot resize an array that references or is referenced estimator_weights\_ : numpy.ndarray of floats, shape = (len(estimators\
951E by another array in this way.
952E Use the np.resize function or refcheck=False_),)
Weights for each estimator in the boosted ensemble. Weights for each estimator in the boosted ensemble.
estimator_errors_ : array of floats estimator_errors_ : array of floats
...@@ -149,9 +141,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -149,9 +141,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
>>> from sklearn.tree import DecisionTreeClassifier >>> from sklearn.tree import DecisionTreeClassifier
>>> base_estimator = DecisionTreeClassifier(max_depth=2) >>> base_estimator = DecisionTreeClassifier(max_depth=2)
>>> clf = MumboClassifier(base_estimator=base_estimator, random_state=0) >>> clf = MumboClassifier(base_estimator=base_estimator, random_state=0)
>>> clf.fit(X, y, views_ind) # doctest: +NORMALIZE_WHITESPACE ValueError: cannot resize an array that references or is referenced >>> clf.fit(X, y, views_ind) # doctest: +NORMALIZE_WHITESPACE
951E by another array in this way.
952E Use the np.resize function or refcheck=False
MumboClassifier(base_estimator=DecisionTreeClassifier(max_depth=2), MumboClassifier(base_estimator=DecisionTreeClassifier(max_depth=2),
random_state=0) random_state=0)
>>> print(clf.predict([[ 5., 3., 1., 1.]])) >>> print(clf.predict([[ 5., 3., 1., 1.]]))
...@@ -167,9 +157,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -167,9 +157,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
---------- ----------
.. [1] Sokol Koço, .. [1] Sokol Koço,
"Tackling the uneven views problem with cooperation based ensemble "Tackling the uneven views problem with cooperation based ensemble
learning methods", ValueError: cannot resize an array that references or is referenced learning methods",
951E by another array in this way.
952E Use the np.resize function or refcheck=False
""" """
def __init__(self, def __init__(self,
...@@ -183,9 +171,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting): ...@@ -183,9 +171,7 @@ class MumboClassifier(BaseEnsemble, ClassifierMixin, UBoosting):
self.n_estimators = n_estimators self.n_estimators = n_estimators
self.estimator_params = [tuple() for _ in base_estimator] self.estimator_params = [tuple() for _ in base_estimator]
else: ValueError: cannot resize an array that references or is referenced else:
951E by another array in this way.
952E Use the np.resize function or refcheck=False
super(MumboClassifier, self).__init__( super(MumboClassifier, self).__init__(
base_estimator=base_estimator, base_estimator=base_estimator,
n_estimators=n_estimators) n_estimators=n_estimators)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment