TNO Quantum: Machine Learning - Components
TNO Quantum provides generic software components aimed at facilitating the development of quantum applications.
This package contains generic components for our machine learning packages.
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.components package can be found here.
Install
Easily install the tno.quantum.ml.components package using pip:
$ python -m pip install tno.quantum.ml.components
Usage
The Quantum Machine Learning Components package allows you to define custom scikit-learn-compatible estimators that depend on solving QUBO problems.
from __future__ import annotations
from typing import TYPE_CHECKING, Self
import numpy as np
from numpy.typing import NDArray
from sklearn.base import ClusterMixin
from tno.quantum.ml.components import QUBOEstimator
if TYPE_CHECKING:
from tno.quantum.optimization.qubo.components import QUBO
from tno.quantum.utils import BitVectorLike
class CustomQUBOClustering(ClusterMixin, QUBOEstimator):
"""Custom QUBO clustering for demonstration purposes.
This is **NOT** a functional clustering class but serves as an example of how to
implement a QUBO estimator in the TNO Quantum framework.
"""
def _check_X_and_y(
self, X: NDArray[np.float64], y: NDArray[np.float64] | None = None
) -> None:
if y is None:
error_msg = (
"This estimator requires target values (y) to be provided for training."
)
raise ValueError(error_msg)
def _make_qubo(
self, X: NDArray[np.float64], y: NDArray[np.float64] | None = None
) -> QUBO:
# Create here the QUBO matrix based on the input data.
pass
def _check_constraints(self, bit_vector: BitVectorLike) -> bool:
# No specific constraints for this classifier.
return True
def _decode_bit_vector(self, bit_vector: BitVectorLike) -> Self:
# Decode the bit vector to return the classifier instance.
return self
For a more complete and functional example, see the QKMedoids implementation.
Metadata
Release files for tno.quantum.ml.components 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tno_quantum_ml_components-2.0.3.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tno_quantum_ml_components-2.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / tno_quantum_ml_components-2.0.3.tar.gz
| Download URL | tno_quantum_ml_components-2.0.3.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e968705dee79806c2212e3adb109a693b2654ffb69fb8e6b79fac7c8f296a88
|
|
BLAKE2b-256 checksum How to use checksums |
30825de9b9dd59de4a044df0b5e31d31e69d37d52882f7bd494f8b261ad49844
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / tno_quantum_ml_components-2.0.3-py3-none-any.whl
| Download URL | tno_quantum_ml_components-2.0.3-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ab67ee0622eeb740506e610b2dfa17368ec49d386f089ddd4db3bf3ffd3f748
|
|
BLAKE2b-256 checksum How to use checksums |
381875a6398aa5d6ca2a22d5e3da47212471148ae9df0a4e7f409ef771171ae8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|