Reputation: 117
I have a code that gives me the accuracy of a SVM, but I want to know how many is class 0 and 1.
Here is the code
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
clf = SVC(C=10000.0, kernel='rbf')
t0 = time()
clf.fit(features_train, labels_train)
print "training_time:", round(time()-t0, 3), "s"
t0 = time()
pred = clf.predict(features_test)
print "prediction time:", round(time()-t0, 3), "s"
acc = accuracy_score(pred, labels_test)
print acc
I have tried this code below, but no success...
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
clf = SVC(C=10000.0, kernel='rbf', probability=True)
t0 = time()
clf.fit(features_train, labels_train)
print "training_time:", round(time()-t0, 3), "s"
t0 = time()
pred = clf.predict(features_test)
class = clf.predict_proba(features_test)
print sum(class)
print "prediction time:", round(time()-t0, 3), "s"
acc = accuracy_score(pred, labels_test)
print acc
What am I missing? Ty!
Upvotes: 0
Views: 194
Reputation: 16966
You can create the confusion matrix to understand your prediction
from sklearn.metrics import confusion_matrix
confusion_matrix(labels_test, pred)
Upvotes: 1