# Performance metrics in QSVM

I have implemented QSVM on breast cancer dataset using link: "https://qiskit.org/documentation/stable/0.24/tutorials/machine_learning/01_qsvm_classification.html" but unable to compute other metrics such as sensitivity, specificity and F1-score. Only able to compute accuracy.

How can I compute other metrics in QSVM?

• The QSVM code is part of Qiskit Aqua which was deprecated and is no longer supported. The QSVM became (moved/refactored) QSVC as part of Qiskit Machine Learning. See qiskit.org/documentation/machine-learning/tutorials/… for a tutorial. This directly extends sklearn SVC, (or you can use the kernel directly as a callable to SVC) As sklearn provides functions for the metrics you are looking for that may be path you can try. May 20 at 16:09
• You can also refer to this tutorial for QSVM, github.com/qiskit-community/… May 22 at 20:10

Other metrics, such as accuracy, recall, f1, and confusion matrix, can be calculated in the same way as in classical machine learning. sklearn already contains built-in functions. So, for example, if you want to view the precision, recall, and F1-score, you may use the classification report function from sklearn.metrics:

classification_report(test_labels, qsvc.predict(test_features))

Here,

qsvc is the name of your quantum kernel

In some cases, kernel matrices are used instead of the test_data in that case you can directly put the test_matrix in the predict function to evaluate your model.

• Thank you. But can you explain this taking an example. It would be of help to me May 24 at 15:12
• The code that I have written is an extension of the tutorial in steve's comment. Please try it out yourself May 24 at 21:48
• Thank you. It worked for QSVM. Can the same code work for VQC as well using vqc.predict. When i try it gives value error: Inconsistent number of samples. May 25 at 11:03
• This error is coming out because your training and test data do not have the same length. Try reshaping your data with NumPy. Another suggestion I have for you is to first learn the fundamentals of classical machine learning before diving into quantum machine learning algorithms. You must comprehend the fundamentals of the traditional algorithm. Otherwise, coding these algorithms would be extremely difficult for you. May 25 at 11:23