TNO Quantum: ML - Classification - KMedoid
TNO Quantum provides generic software components aimed at facilitating the development of quantum applications.
This package implements a scikit-learn compatible kmedoid clustering.
Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.
Documentation
Documentation of the tno.quantum.ml.clustering.kmedoids package can be found here.
Install
Easily install the tno.quantum.ml.clustering.kmedoids package using pip:
$ python -m pip install tno.quantum.ml.clustering.kmedoid
Example
The K-medoids clustering can be used as shown in the following example.
-
Note: This example requires
tno.quantum.optimization.solvers[dwave]andtno.quantum.ml.datasetswhich can be installed along the package using:$ python -m pip install tno.quantum.ml.clustering.kmedoids[example]
import matplotlib.pyplot as plt
import numpy as np
from tno.quantum.ml.datasets import get_blobs_clustering_dataset
from tno.quantum.ml.clustering.kmedoids import QKMedoids
# Generate sample data
n_centers = 6
X, true_labels = get_blobs_clustering_dataset(
n_samples=120, n_features=2, n_centers=n_centers
)
# Create QKMedoids object and fit
cobj = QKMedoids(
n_clusters=n_centers,
solver_config={
"name": "simulated_annealing_solver",
"options": {"random_state": 42},
},
)
pred_labels = cobj.fit_predict(X)
# Plot results
fig, ax = plt.subplots(nrows=1, ncols=1)
unique_labels = np.unique(pred_labels)
colors = plt.cm.Spectral(np.linspace(0, 1, len(unique_labels)))
for k, col in zip(unique_labels, colors):
class_member_mask = cobj.labels_ == k
xy = X[class_member_mask]
x, y = np.split(xy, 2, axis=1)
ax.plot(x, y, "o", mfc=tuple(col), mec="k", ms=6)
x_centers, y_centers = np.split(cobj.cluster_centers_, 2, axis=1)
ax.plot(x_centers, y_centers, "o", mfc="cyan", mec="k", ms=6)
ax.set_title("Quantum KMedoids clustering")
plt.show()
We refer to the documentation for more information regarding possible parameters.
Metadata
Release files for tno.quantum.ml.clustering.kmedoids 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tno_quantum_ml_clustering_kmedoids-2.0.2.tar.gz | 34.1 kB | Without provenance | Details for tno_quantum_ml_clustering_kmedoids-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tno_quantum_ml_clustering_kmedoids-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for tno_quantum_ml_clustering_kmedoids-2.0.2-py3-none-any.whl |
Total release size: 66.3 kB
Release files / tno_quantum_ml_clustering_kmedoids-2.0.2.tar.gz
| Download URL | tno_quantum_ml_clustering_kmedoids-2.0.2.tar.gz |
|---|---|
| Size | 34.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1dafa4a0a32401ba2094c0b155602bf8d4aa5d795ee9221497705631c58b5fdb
|
|
BLAKE2b-256 checksum How to use checksums |
42a0e6a1bf3bc215844ec381c707f408e08e02af3c7a7e12d9a1527994989a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / tno_quantum_ml_clustering_kmedoids-2.0.2-py3-none-any.whl
| Download URL | tno_quantum_ml_clustering_kmedoids-2.0.2-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34c6f3813feeace7666c0aaa195d6c838b6c96c3d1b2a9671fb47e3b1e63d990
|
|
BLAKE2b-256 checksum How to use checksums |
5f81b5309114fa86c1aa8973eb86175c484a213bf241fb547f14ec4e1a22c196
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Security for tno.quantum.ml.clustering.kmedoids 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.