Skip to main content

Quantum Kernel Method

🌽

Quantum Kernel Method by Rigetti​

The Rigetti Quantum Kernel Method (QKM) is a Quantum Machine Learning (QML) application offered for use with Rigetti backends.

The algorithm is designed for classification and regression problems. It assesses similarities between data points in a quantum-enhanced space, useful for models like anomaly detection.

For installation, authentication, and detailed instructions on the Rigetti SDK, refer to the Rigetti product page.

🚀

Quickstart​

Here is an example on how to run a simple classification problem using the Quantum Kernel Method.

In this example, we will use the Iris dataset, a well-known dataset for classification tasks. Before running the example, ensure that the scikit-learn library is installed.

pip install scikit-learn
from sklearn.datasets import load_iris

import strangeworks as sw
from strangeworks.rigetti import get_qc

sw.authenticate(api_key)

# Standard machine learning training and test data
iris_data = load_iris()
X_train, X_test, y_train, y_test = iris_data.data, iris_data.data, iris_data.target, iris_data.target

data = {
"resource": "WavefunctionSimulator",
"num_shots": 1,
"X_train": X_train.tolist(), # expected as python list
"X_test": X_test.tolist(), # expected as python list
"y_train": y_train.tolist(), # expected as python list
"y_test": y_test.tolist(), # expected as python list
}

qc = get_qc("WavefunctionSimulator", as_qvm=True)

res = qc.run(data)

print(res)

​🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!