Quantum Kernel SVM#

This tutorial shows how to use QSVC with FidelityQuantumKernel.

Setup#

from sklearn.datasets import make_circles
from sklearn.model_selection import train_test_split
from psipose.estimators import QSVC
from psipose.kernels import FidelityQuantumKernel

Generate Data#

X, y = make_circles(n_samples=100, noise=0.1, factor=0.5, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.3, random_state=42
)

Train Quantum Kernel SVM#

kernel = FidelityQuantumKernel()
svc = QSVC(kernel=kernel)
svc.fit(X_train, y_train)

print(f"Accuracy: {svc.score(X_test, y_test):.2%}")