1

I used the SVM.SVC function to classify. But when I wanted to calculate the weighted and unweighted average accuracy, I couldn't access the confusion matrix. Because svm.SVC.score only provides a classifier accuracy percentage. How can I calculate WAR and UAR?

You can find part of my script below:

scaler = StandardScaler()
scaler.fit(trainX)
trainXsc = scaler.transform(trainX)
testXsc = scaler.transform(testX)

pca = KernelPCA(n_components=j, kernel="sigmoid", random_state=1)  

pca.fit(trainXsc)     # fit pca kernel with train data

trainXtr    = pca.transform(trainXsc) # transform FV with PCA and dimension reduction
testXtr     = pca.transform(testXsc)

svmObject   = svm.SVC(C=2.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True,
              probability=False, tol=0.001, cache_size=200, class_weight=None,
              verbose=False, max_iter=-1, decision_function_shape='ovo', random_state=None)
                                    # SVM Kernel Function

svmObject.fit(trainXtr, trainY)      # train SVM kernel with train FV

result = svmObject.score(testXtr, testY) 
dspencer
  • 4,297
  • 4
  • 22
  • 43
  • I got my answer in the following link: https://datascience.stackexchange.com/questions/71929/not-access-to-confusion-matrix-in-svm-svc-score-scikit-learn-python – Farid J. Maleki Apr 19 '20 at 22:04

0 Answers0