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
• 15,510 points
1,186 views

1 answer to this question.

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
• 58,020 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,560 points
1,528 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,560 points
1,739 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 13, 2019 in Python by Shaam
990 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,457 views
0 votes
1 answer
+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
• 69,220 points
1,071 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
• 58,020 points
620 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP