-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve
Description
Description
ValueError when using an array for setting weights (it works with list)
Steps/Code to Reproduce
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier as RFC
from sklearn.neighbors import KNeighborsClassifier as KNC
from sklearn.ensemble import VotingClassifier as VC
import numpy as np
X, y = load_iris(return_X_y=True)
models=[('knc', KNC()),('rnc', KNC())]
weights=np.array((1,2))
vc = VC(estimators=models, weights=weights)
vc.fit(X,y)
Actual Results
ValueError Traceback (most recent call last)
<ipython-input-6-cc5618b5c2ae> in <module>()
9 weights=np.array((1,2))
10 vc = VC(estimators=models, weights=weights)
---> 11 vc.fit(X,y)
142 ' tuples')
143
--> 144 if self.weights and len(self.weights) != len(self.estimators):
145 raise ValueError('Number of classifiers and weights must be equal'
146 '; got %d weights, %d estimators'
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Versions
Windows-10-10.0.14393
('Python', '2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)]')
('NumPy', '1.11.0')
('SciPy', '0.17.1')
('Scikit-Learn', '0.18')
Metadata
Metadata
Assignees
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve