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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file qmeans-0.1.2.tar.gz.

File metadata

  • Download URL: qmeans-0.1.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for qmeans-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3c8d7af1c38cff532be080711452be958898ea8b346595fcdf1b9a45048053fa
MD5 8f47dae248522a48a28c4496b200c821
BLAKE2b-256 4a094b864e3b80d407fa15b9c293651466681ea680fac77d4a0252283cac6da1

See more details on using hashes here.

File details

Details for the file qmeans-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: qmeans-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for qmeans-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1dab3f2e3aaf2853de16b641c7bcd4d42953393e1fddaef8aab31fd0f2d5c75
MD5 dc3d03f34dc0f27b55d3035f3c47aa5a
BLAKE2b-256 78097630174794d1df1d86211aa832e1e31de43a11bc217a3cabe5a6a89d306e

See more details on using hashes here.

Supported by

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