How to evaluate a soft Voting classifier being trained on some data

0 votes

I have taken 3 classification models,

clf1 = DecisionTreeClassifier(max_depth=4)
clf2 = KNeighborsClassifier(n_neighbors=7)
clf3 = SVC(kernel='rbf', probability=True)

I am passing them to voting classifier as parameters and choose soft voting.

eclf = VotingClassifier(estimators=[('dt', clf1), ('knn', clf2), ('svc', clf3)], voting='soft', weights=[2,1,2])

clf1 = clf1.fit(titanic_train1,y_train)
clf2 = clf2.fit(titanic_train1,y_train)
clf3 = clf3.fit(titanic_train1,y_train)
eclf = eclf.fit(titanic_train1,y_train)

Here i am getting error ,AttributeError: 'VotingClassifier' object has no attribute 'best_score_'

print("CvScore",eclf.best_score_)
print("Train accuracy",eclf.score(titanic_train1, y_train))

I want to find best tuning parameters for this model?

Sep 6, 2018 in Python by bug_seeker
• 14,970 points
35 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

VotingClassifier does not have a best_score_ attribute. You can look at the scikit-learn documentation here to see that the best_score_ attribute is missing.

If you're trying to get a cross validation score you need to use something like K-Fold or GridSearchCV where K-Fold will give you an idea for how well the classifier generalizes to naive data and GridSearchCV will help determine the best parameter configuration for the model.

answered Sep 6, 2018 by Priyaj
• 56,120 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

List comprehension on a nested list - How to do it in Python?

Not sure what your desired output is, ...READ MORE

answered Nov 21, 2018 in Python by Nymeria
• 3,500 points
36 views
0 votes
1 answer

Question on PyQt: How to connect a signal to a slot to start a background operation in Python

It shouldn't matter whether the connection is ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,500 points
78 views
0 votes
1 answer

How to write data to a file in Python?

Refer to the below code. data=’whatever your data ...READ MORE

answered May 12 in Python by Shaam
6 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
22 views
+1 vote
2 answers

Appending data to a file

First open the file that you want ...READ MORE

answered Jul 23, 2018 in Python by Omkar
• 65,850 points
22 views
0 votes
1 answer

How do you append to a file?

with open("test.txt", "a") as myfile: myfile.write("appended text" ...READ MORE

answered Jul 27, 2018 in Python by Priyaj
• 56,120 points
18 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.