Skip to main content

Q-Means algorithm implementation using Qiskit compatible with Scikit-Learn.

Project description

GitHub license Linter codecov

Clustering example
Q-Means algorithm implementation using Qiskit compatible with Scikit-Learn.

The q-means leverages quantum computing to calculate distances for the centroid assignment part of the k-means unsupervised learning algorithm. It shares the same general steps its classical counterpart has, and is used alongside quantum simulators and quantum devices. This implementation uses Qiskit and is compatible with the scikit-learn library in order to exploit the capabilities for machine learning offered by scikit-learn. You can use the q-means in the same way you would use the k-means, and many options are available for data encoding and job batching.

:exclamation: Job batching is introduced as a way to speed up training time on quantum devices for larger datasets. [2]

Installation

The project is publicly available in PyPI and can be installed using the following command:

pip install qmeans

Usage

Example code for usage of the qmeans algorithm:

import numpy as np
import pandas as pd
from qmeans.qkmeans import *

backend = Aer.get_backend("aer_simulator_statevector")
X = pd.DataFrame(np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]))
qk_means = QuantumKMeans(backend, n_clusters=2, verbose=True)
qk_means.fit(X)
print(qk_means.labels_)

Requirements

Python 3.6+

Q-Means uses Qiskit for quantum computations, Scikit-Learn for data preparation and estimator formatting, and Pandas and Numpy for data manipulation.

Publications

[1]: D. Quiroga, P. Date and R. Pooser, "Discriminating Quantum States with Quantum Machine Learning," 2021 IEEE International Conference on Quantum Computing and Engineering (QCE), 2021, pp. 481-482, doi: 10.1109/QCE52317.2021.00088.

[2]: D. Quiroga, P. Date and R. Pooser, "Discriminating Quantum States with Quantum Machine Learning," 2021 International Conference on Rebooting Computing (ICRC), 2021, pp. 56-63, doi: 10.1109/ICRC53822.2021.00018.

[3]: D. Quiroga, J. Botia, "Q-means clustering coherent noise tolerance analysis," International Congress EXPOIngenieria, 2022, pp. 437-443.

License

This source code is free and open source, released under the Apache License, Version 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qmeans-0.1.2.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

qmeans-0.1.2-py3-none-any.whl (14.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page