lazyqml 3.0.5__tar.gz → 3.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. lazyqml-3.0.6/PKG-INFO +255 -0
  2. lazyqml-3.0.6/README.md +216 -0
  3. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/__init__.py +1 -1
  4. lazyqml-3.0.6/lazyqml.egg-info/PKG-INFO +255 -0
  5. {lazyqml-3.0.5 → lazyqml-3.0.6}/pyproject.toml +2 -2
  6. lazyqml-3.0.5/PKG-INFO +0 -122
  7. lazyqml-3.0.5/README.md +0 -83
  8. lazyqml-3.0.5/lazyqml.egg-info/PKG-INFO +0 -122
  9. {lazyqml-3.0.5 → lazyqml-3.0.6}/.editorconfig +0 -0
  10. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  11. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  12. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  13. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/workflows/docs-build.yml +0 -0
  14. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/workflows/docs.yml +0 -0
  15. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/workflows/installation.yml +0 -0
  16. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/workflows/pypi.yml +0 -0
  17. {lazyqml-3.0.5 → lazyqml-3.0.6}/.github/workflows/ubuntu.yml +0 -0
  18. {lazyqml-3.0.5 → lazyqml-3.0.6}/.gitignore +0 -0
  19. {lazyqml-3.0.5 → lazyqml-3.0.6}/AUTHORS.rst +0 -0
  20. {lazyqml-3.0.5 → lazyqml-3.0.6}/LICENSE +0 -0
  21. {lazyqml-3.0.5 → lazyqml-3.0.6}/LICENSE copy +0 -0
  22. {lazyqml-3.0.5 → lazyqml-3.0.6}/MANIFEST.in +0 -0
  23. {lazyqml-3.0.5 → lazyqml-3.0.6}/README copy.md +0 -0
  24. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/authors.rst +0 -0
  25. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/changelog.md +0 -0
  26. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/common.md +0 -0
  27. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/contributing.md +0 -0
  28. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/examples/intro.ipynb +0 -0
  29. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/faq.md +0 -0
  30. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/index.md +0 -0
  31. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/installation.md +0 -0
  32. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/lazyqml.md +0 -0
  33. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/overrides/main.html +0 -0
  34. {lazyqml-3.0.5 → lazyqml-3.0.6}/docs/usage.md +0 -0
  35. {lazyqml-3.0.5 → lazyqml-3.0.6}/experimentallibs.txt +0 -0
  36. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/AmplitudeEmbedding.py +0 -0
  37. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/HCzRx.py +0 -0
  38. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/HardwareEfficient.py +0 -0
  39. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/RxEmbedding.py +0 -0
  40. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/RyEmbedding.py +0 -0
  41. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/RzEmbedding.py +0 -0
  42. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/TreeTensor.py +0 -0
  43. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/TwoLocal.py +0 -0
  44. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/ZzEmbedding.py +0 -0
  45. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Circuits/fCircuits.py +0 -0
  46. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Dispatchers/Dispatcher.py +0 -0
  47. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/Hybrid.py +0 -0
  48. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/QNNBag.py +0 -0
  49. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/QNNTorch.py +0 -0
  50. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/QSVM.py +0 -0
  51. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/_QNNPennylane.py +0 -0
  52. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Models/fModels.py +0 -0
  53. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Preprocessing/Pca.py +0 -0
  54. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Preprocessing/Sanitizer.py +0 -0
  55. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Preprocessing/__init__.py +0 -0
  56. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/Preprocessing/fPreprocessing.py +0 -0
  57. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Factories/__init__.py +0 -0
  58. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Global/globalEnums.py +0 -0
  59. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Interfaces/__init__.py +0 -0
  60. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Interfaces/iAnsatz.py +0 -0
  61. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Interfaces/iCircuit.py +0 -0
  62. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Interfaces/iModel.py +0 -0
  63. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Interfaces/iPreprocessing.py +0 -0
  64. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Utils/Utils.py +0 -0
  65. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/Utils/Validator.py +0 -0
  66. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml/lazyqml.py +0 -0
  67. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml.egg-info/SOURCES.txt +0 -0
  68. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml.egg-info/dependency_links.txt +0 -0
  69. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml.egg-info/entry_points.txt +0 -0
  70. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml.egg-info/requires.txt +0 -0
  71. {lazyqml-3.0.5 → lazyqml-3.0.6}/lazyqml.egg-info/top_level.txt +0 -0
  72. {lazyqml-3.0.5 → lazyqml-3.0.6}/mkdocs.yml +0 -0
  73. {lazyqml-3.0.5 → lazyqml-3.0.6}/requirements.txt +0 -0
  74. {lazyqml-3.0.5 → lazyqml-3.0.6}/requirements_dev.txt +0 -0
  75. {lazyqml-3.0.5 → lazyqml-3.0.6}/setup.cfg +0 -0
  76. {lazyqml-3.0.5 → lazyqml-3.0.6}/tests/__init__.py +0 -0
  77. {lazyqml-3.0.5 → lazyqml-3.0.6}/tests/test_lazyqml.py +0 -0
lazyqml-3.0.6/PKG-INFO ADDED
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.1
2
+ Name: lazyqml
3
+ Version: 3.0.6
4
+ Summary: LazyQML benchmarking utility to test quantum machine learning models.
5
+ Author-email: QHPC Group <qhpcgroup@gmail.com>
6
+ License: MIT License
7
+ Project-URL: Homepage, https://github.com/QHPC-SP-Research-Lab/LazyQML
8
+ Keywords: lazyqml
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ License-File: LICENSE copy
17
+ License-File: AUTHORS.rst
18
+ Requires-Dist: wheel
19
+ Requires-Dist: tabulate
20
+ Requires-Dist: torch
21
+ Requires-Dist: torchaudio
22
+ Requires-Dist: torchvision
23
+ Requires-Dist: scipy
24
+ Requires-Dist: scikit-learn
25
+ Requires-Dist: PennyLane
26
+ Requires-Dist: PennyLane_Lightning
27
+ Requires-Dist: PennyLane_Lightning_GPU
28
+ Requires-Dist: custatevec_cu12
29
+ Requires-Dist: ucimlrepo
30
+ Requires-Dist: pydantic
31
+ Requires-Dist: psutil
32
+ Requires-Dist: pandas
33
+ Requires-Dist: joblib
34
+ Requires-Dist: gputil
35
+ Provides-Extra: all
36
+ Requires-Dist: lazyqml[extra]; extra == "all"
37
+ Provides-Extra: extra
38
+ Requires-Dist: pandas; extra == "extra"
39
+
40
+ # LazyQML
41
+
42
+
43
+ [![image](https://img.shields.io/badge/pypi-%23ececec.svg?style=for-the-badge&logo=pypi&logoColor=1f73b7)](https://pypi.python.org/pypi/lazyqml)
44
+ ![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)
45
+ ![NumPy](https://img.shields.io/badge/numpy-%23013243.svg?style=for-the-badge&logo=numpy&logoColor=white)
46
+ ![Pandas](https://img.shields.io/badge/pandas-%23150458.svg?style=for-the-badge&logo=pandas&logoColor=white)
47
+ ![PyTorch](https://img.shields.io/badge/PyTorch-%23EE4C2C.svg?style=for-the-badge&logo=PyTorch&logoColor=white)
48
+ ![scikit-learn](https://img.shields.io/badge/scikit--learn-%23F7931E.svg?style=for-the-badge&logo=scikit-learn&logoColor=white)
49
+ ![nVIDIA](https://img.shields.io/badge/cuda-000000.svg?style=for-the-badge&logo=nVIDIA&logoColor=green)
50
+ <img src="https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg" alt="Pennylane Logo" style="background-color: white; padding: 2px;" />
51
+ ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)
52
+
53
+ <!-- ![Pennylane](https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg) -->
54
+
55
+ pLazyQML, a software package designed to accelerate, automate, and streamline experimentation with quantum machine learning models on classical computers. pLazyQML reduces the complexity and time required for developing and testing quantum-enhanced machine learning models.
56
+
57
+ ## Installation
58
+ ```bash
59
+ $ pip install lazyqml --upgrade
60
+ ```
61
+ ## Usage
62
+ ```python
63
+ from sklearn.datasets import load_iris
64
+ from lazyqml.lazyqml import *
65
+
66
+ # Load data
67
+ data = load_iris()
68
+ X = data.data
69
+ y = data.target
70
+
71
+ classifier = QuantumClassifier(nqubits={4}, classifiers={Model.QNN, Model.QSVM}, epochs=10)
72
+
73
+ # Fit and predict
74
+ classifier.fit(X=X, y=y, test_size=0.4)
75
+ ```
76
+ ### Output
77
+ | Qubits | Model | Embedding | Ansatz | Time taken | Accuracy | Balanced Accuracy | F1 Score |
78
+ |---------:|:-----------|:--------------|:---------------------------|-------------:|-----------:|--------------------:|-----------:|
79
+ | 4 | Model.QSVM | Embedding.RZ | | 18.2478 | 0.966667 | 0.966667 | 0.966583 |
80
+ | 4 | Model.QSVM | Embedding.RY | | 13.8088 | 0.966667 | 0.966667 | 0.966583 |
81
+ | 4 | Model.QSVM | Embedding.RX | | 13.7079 | 0.966667 | 0.966667 | 0.966583 |
82
+ | 4 | Model.QNN | Embedding.RX | Ansatzs.HARDWARE_EFFICIENT | 11.1699 | 0.933333 | 0.933333 | 0.932896 |
83
+ | 4 | Model.QNN | Embedding.RZ | Ansatzs.HARDWARE_EFFICIENT | 11.7565 | 0.9 | 0.9 | 0.899206 |
84
+ | 4 | Model.QNN | Embedding.RY | Ansatzs.HARDWARE_EFFICIENT | 11.8614 | 0.9 | 0.9 | 0.899948 |
85
+
86
+
87
+ ## License & Compatibility
88
+ - Free software: MIT License
89
+ - This Python package is only compatible with Linux systems.
90
+ - Hardware acceleration is only enabled using CUDA-compatible devices.
91
+ ## Quantum and High Performance Computing (QHPC) - University of Oviedo
92
+ - José Ranilla Pastor - ranilla@uniovi.es
93
+ - Elías Fernández Combarro - efernandezca@uniovi.es
94
+ - Diego García Vega - diegogarciavega@gmail.com
95
+ - Fernando Álvaro Plou Llorente - ploufernando@uniovi.es
96
+ - Alejandro Leal Castaño - lealcalejandro@uniovi.es
97
+ - Group - https://qhpc.uniovi.es
98
+
99
+ ## QuantumClassifier Parameters:
100
+ #### Core Parameters:
101
+ - **`nqubits`**: `Set[int]`
102
+ - Description: Set of qubit indices, where each value must be greater than 0.
103
+ - Validation: Ensures that all elements are integers > 0.
104
+
105
+ - **`randomstate`**: `int`
106
+ - Description: Seed value for random number generation.
107
+ - Default: `1234`
108
+
109
+ - **`predictions`**: `bool`
110
+ - Description: Flag to determine if predictions are enabled.
111
+ - Default: `False`
112
+
113
+ #### Model Structure Parameters:
114
+ - **`numPredictors`**: `int`
115
+ - Description: Number of predictors used in the QNN with bagging.
116
+ - Constraints: Must be greater than 0.
117
+ - Default: `10`
118
+
119
+ - **`numLayers`**: `int`
120
+ - Description: Number of layers in the Quantum Neural Networks.
121
+ - Constraints: Must be greater than 0.
122
+ - Default: `5`
123
+
124
+ #### Set-Based Configuration Parameters:
125
+ - **`classifiers`**: `Set[Model]`
126
+ - Description: Set of classifier models.
127
+ - Constraints: Must contain at least one classifier.
128
+ - Default: `{Model.ALL}`
129
+ - Options: `{Model.QNN, Model.QSVM, Model.QNN_BAG}`
130
+
131
+ - **`ansatzs`**: `Set[Ansatzs]`
132
+ - Description: Set of quantum ansatz configurations.
133
+ - Constraints: Must contain at least one ansatz.
134
+ - Default: `{Ansatzs.ALL}`
135
+ - Options: `{Ansatzs.RX, Ansatzs.RZ, Ansatzs.RY, Ansatzs.ZZ, Ansatzs.AMP}`
136
+
137
+ - **`embeddings`**: `Set[Embedding]`
138
+ - Description: Set of embedding strategies.
139
+ - Constraints: Must contain at least one embedding.
140
+ - Default: `{Embedding.ALL}`
141
+ - Options: `{Embedding.HCZRX, Embedding.TREE_TENSOR, Embedding.TWO_LOCAL, Embedding.HARDWARE_EFFICENT}`
142
+
143
+ - **`features`**: `Set[float]`
144
+ - Description: Set of feature values (must be between 0 and 1).
145
+ - Constraints: Values > 0 and <= 1.
146
+ - Default: `{0.3, 0.5, 0.8}`
147
+
148
+ #### Training Parameters:
149
+ - **`learningRate`**: `float`
150
+ - Description: Learning rate for optimization.
151
+ - Constraints: Must be greater than 0.
152
+ - Default: `0.01`
153
+
154
+ - **`epochs`**: `int`
155
+ - Description: Number of training epochs.
156
+ - Constraints: Must be greater than 0.
157
+ - Default: `100`
158
+
159
+ - **`batchSize`**: `int`
160
+ - Description: Size of each batch during training.
161
+ - Constraints: Must be greater than 0.
162
+ - Default: `8`
163
+
164
+ #### Threshold and Sampling:
165
+ - **`threshold`**: `int`
166
+ - Description: Decision threshold for parallelization, if the model is bigger than this threshold it will use GPU.
167
+ - Constraints: Must be greater than 0.
168
+ - Default: `22`
169
+
170
+ - **`maxSamples`**: `float`
171
+ - Description: Maximum proportion of samples to be used from the dataset characteristics.
172
+ - Constraints: Between 0 and 1.
173
+ - Default: `1.0`
174
+
175
+ #### Logging and Metrics:
176
+ - **`verbose`**: `bool`
177
+ - Description: Flag for detailed output during training.
178
+ - Default: `False`
179
+
180
+ - **`customMetric`**: `Optional[Callable]`
181
+ - Description: User-defined metric function for evaluation.
182
+ - Validation:
183
+ - Function must accept `y_true` and `y_pred` as the first two arguments.
184
+ - Must return a scalar value (int or float).
185
+ - Function execution is validated with dummy arguments.
186
+ - Default: `None`
187
+
188
+ #### Custom Preprocessors:
189
+ - **`customImputerNum`**: `Optional[Any]`
190
+ - Description: Custom numeric data imputer.
191
+ - Validation:
192
+ - Must be an object with `fit`, `transform`, and optionally `fit_transform` methods.
193
+ - Validated with dummy data.
194
+ - Default: `None`
195
+
196
+ - **`customImputerCat`**: `Optional[Any]`
197
+ - Description: Custom categorical data imputer.
198
+ - Validation:
199
+ - Must be an object with `fit`, `transform`, and optionally `fit_transform` methods.
200
+ - Validated with dummy data.
201
+ - Default: `None`
202
+
203
+ ## Functions:
204
+
205
+ ### **`fit`**
206
+ ```python
207
+ fit(self, X, y, test_size=0.4, showTable=True)
208
+ ```
209
+ Fits classification algorithms to `X` and `y` using a hold-out approach. Predicts and scores on a test set determined by `test_size`.
210
+
211
+ #### Parameters:
212
+ - **`X`**: Input features (DataFrame or compatible format).
213
+ - **`y`**: Target labels (must be numeric, e.g., via `LabelEncoder` or `OrdinalEncoder`).
214
+ - **`test_size`**: Proportion of the dataset to use as the test set. Default is `0.4`.
215
+ - **`showTable`**: Display a table with results. Default is `True`.
216
+
217
+ #### Behavior:
218
+ - Validates the compatibility of input dimensions.
219
+ - Automatically applies PCA transformation for incompatible dimensions.
220
+ - Requires all categories to be present in training data.
221
+
222
+ ### **`repeated_cross_validation`**
223
+ ```python
224
+ repeated_cross_validation(self, X, y, n_splits=10, n_repeats=5, showTable=True)
225
+ ```
226
+ Performs repeated cross-validation on the dataset using the specified splits and repeats.
227
+
228
+ #### Parameters:
229
+ - **`X`**: Input features (DataFrame or compatible format).
230
+ - **`y`**: Target labels (must be numeric).
231
+ - **`n_splits`**: Number of folds for splitting the dataset. Default is `10`.
232
+ - **`n_repeats`**: Number of times cross-validation is repeated. Default is `5`.
233
+ - **`showTable`**: Display a table with results. Default is `True`.
234
+
235
+ #### Behavior:
236
+ - Uses `RepeatedStratifiedKFold` for generating splits.
237
+ - Aggregates results from multiple train-test splits.
238
+
239
+ ### **`leave_one_out`**
240
+ ```python
241
+ leave_one_out(self, X, y, showTable=True)
242
+ ```
243
+ Performs leave-one-out cross-validation on the dataset.
244
+
245
+ #### Parameters:
246
+ - **`X`**: Input features (DataFrame or compatible format).
247
+ - **`y`**: Target labels (must be numeric).
248
+ - **`showTable`**: Display a table with results. Default is `True`.
249
+
250
+ #### Behavior:
251
+ - Uses `LeaveOneOut` for generating train-test splits.
252
+ - Evaluates the model on each split and aggregates results.
253
+
254
+
255
+
@@ -0,0 +1,216 @@
1
+ # LazyQML
2
+
3
+
4
+ [![image](https://img.shields.io/badge/pypi-%23ececec.svg?style=for-the-badge&logo=pypi&logoColor=1f73b7)](https://pypi.python.org/pypi/lazyqml)
5
+ ![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)
6
+ ![NumPy](https://img.shields.io/badge/numpy-%23013243.svg?style=for-the-badge&logo=numpy&logoColor=white)
7
+ ![Pandas](https://img.shields.io/badge/pandas-%23150458.svg?style=for-the-badge&logo=pandas&logoColor=white)
8
+ ![PyTorch](https://img.shields.io/badge/PyTorch-%23EE4C2C.svg?style=for-the-badge&logo=PyTorch&logoColor=white)
9
+ ![scikit-learn](https://img.shields.io/badge/scikit--learn-%23F7931E.svg?style=for-the-badge&logo=scikit-learn&logoColor=white)
10
+ ![nVIDIA](https://img.shields.io/badge/cuda-000000.svg?style=for-the-badge&logo=nVIDIA&logoColor=green)
11
+ <img src="https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg" alt="Pennylane Logo" style="background-color: white; padding: 2px;" />
12
+ ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)
13
+
14
+ <!-- ![Pennylane](https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg) -->
15
+
16
+ pLazyQML, a software package designed to accelerate, automate, and streamline experimentation with quantum machine learning models on classical computers. pLazyQML reduces the complexity and time required for developing and testing quantum-enhanced machine learning models.
17
+
18
+ ## Installation
19
+ ```bash
20
+ $ pip install lazyqml --upgrade
21
+ ```
22
+ ## Usage
23
+ ```python
24
+ from sklearn.datasets import load_iris
25
+ from lazyqml.lazyqml import *
26
+
27
+ # Load data
28
+ data = load_iris()
29
+ X = data.data
30
+ y = data.target
31
+
32
+ classifier = QuantumClassifier(nqubits={4}, classifiers={Model.QNN, Model.QSVM}, epochs=10)
33
+
34
+ # Fit and predict
35
+ classifier.fit(X=X, y=y, test_size=0.4)
36
+ ```
37
+ ### Output
38
+ | Qubits | Model | Embedding | Ansatz | Time taken | Accuracy | Balanced Accuracy | F1 Score |
39
+ |---------:|:-----------|:--------------|:---------------------------|-------------:|-----------:|--------------------:|-----------:|
40
+ | 4 | Model.QSVM | Embedding.RZ | | 18.2478 | 0.966667 | 0.966667 | 0.966583 |
41
+ | 4 | Model.QSVM | Embedding.RY | | 13.8088 | 0.966667 | 0.966667 | 0.966583 |
42
+ | 4 | Model.QSVM | Embedding.RX | | 13.7079 | 0.966667 | 0.966667 | 0.966583 |
43
+ | 4 | Model.QNN | Embedding.RX | Ansatzs.HARDWARE_EFFICIENT | 11.1699 | 0.933333 | 0.933333 | 0.932896 |
44
+ | 4 | Model.QNN | Embedding.RZ | Ansatzs.HARDWARE_EFFICIENT | 11.7565 | 0.9 | 0.9 | 0.899206 |
45
+ | 4 | Model.QNN | Embedding.RY | Ansatzs.HARDWARE_EFFICIENT | 11.8614 | 0.9 | 0.9 | 0.899948 |
46
+
47
+
48
+ ## License & Compatibility
49
+ - Free software: MIT License
50
+ - This Python package is only compatible with Linux systems.
51
+ - Hardware acceleration is only enabled using CUDA-compatible devices.
52
+ ## Quantum and High Performance Computing (QHPC) - University of Oviedo
53
+ - José Ranilla Pastor - ranilla@uniovi.es
54
+ - Elías Fernández Combarro - efernandezca@uniovi.es
55
+ - Diego García Vega - diegogarciavega@gmail.com
56
+ - Fernando Álvaro Plou Llorente - ploufernando@uniovi.es
57
+ - Alejandro Leal Castaño - lealcalejandro@uniovi.es
58
+ - Group - https://qhpc.uniovi.es
59
+
60
+ ## QuantumClassifier Parameters:
61
+ #### Core Parameters:
62
+ - **`nqubits`**: `Set[int]`
63
+ - Description: Set of qubit indices, where each value must be greater than 0.
64
+ - Validation: Ensures that all elements are integers > 0.
65
+
66
+ - **`randomstate`**: `int`
67
+ - Description: Seed value for random number generation.
68
+ - Default: `1234`
69
+
70
+ - **`predictions`**: `bool`
71
+ - Description: Flag to determine if predictions are enabled.
72
+ - Default: `False`
73
+
74
+ #### Model Structure Parameters:
75
+ - **`numPredictors`**: `int`
76
+ - Description: Number of predictors used in the QNN with bagging.
77
+ - Constraints: Must be greater than 0.
78
+ - Default: `10`
79
+
80
+ - **`numLayers`**: `int`
81
+ - Description: Number of layers in the Quantum Neural Networks.
82
+ - Constraints: Must be greater than 0.
83
+ - Default: `5`
84
+
85
+ #### Set-Based Configuration Parameters:
86
+ - **`classifiers`**: `Set[Model]`
87
+ - Description: Set of classifier models.
88
+ - Constraints: Must contain at least one classifier.
89
+ - Default: `{Model.ALL}`
90
+ - Options: `{Model.QNN, Model.QSVM, Model.QNN_BAG}`
91
+
92
+ - **`ansatzs`**: `Set[Ansatzs]`
93
+ - Description: Set of quantum ansatz configurations.
94
+ - Constraints: Must contain at least one ansatz.
95
+ - Default: `{Ansatzs.ALL}`
96
+ - Options: `{Ansatzs.RX, Ansatzs.RZ, Ansatzs.RY, Ansatzs.ZZ, Ansatzs.AMP}`
97
+
98
+ - **`embeddings`**: `Set[Embedding]`
99
+ - Description: Set of embedding strategies.
100
+ - Constraints: Must contain at least one embedding.
101
+ - Default: `{Embedding.ALL}`
102
+ - Options: `{Embedding.HCZRX, Embedding.TREE_TENSOR, Embedding.TWO_LOCAL, Embedding.HARDWARE_EFFICENT}`
103
+
104
+ - **`features`**: `Set[float]`
105
+ - Description: Set of feature values (must be between 0 and 1).
106
+ - Constraints: Values > 0 and <= 1.
107
+ - Default: `{0.3, 0.5, 0.8}`
108
+
109
+ #### Training Parameters:
110
+ - **`learningRate`**: `float`
111
+ - Description: Learning rate for optimization.
112
+ - Constraints: Must be greater than 0.
113
+ - Default: `0.01`
114
+
115
+ - **`epochs`**: `int`
116
+ - Description: Number of training epochs.
117
+ - Constraints: Must be greater than 0.
118
+ - Default: `100`
119
+
120
+ - **`batchSize`**: `int`
121
+ - Description: Size of each batch during training.
122
+ - Constraints: Must be greater than 0.
123
+ - Default: `8`
124
+
125
+ #### Threshold and Sampling:
126
+ - **`threshold`**: `int`
127
+ - Description: Decision threshold for parallelization, if the model is bigger than this threshold it will use GPU.
128
+ - Constraints: Must be greater than 0.
129
+ - Default: `22`
130
+
131
+ - **`maxSamples`**: `float`
132
+ - Description: Maximum proportion of samples to be used from the dataset characteristics.
133
+ - Constraints: Between 0 and 1.
134
+ - Default: `1.0`
135
+
136
+ #### Logging and Metrics:
137
+ - **`verbose`**: `bool`
138
+ - Description: Flag for detailed output during training.
139
+ - Default: `False`
140
+
141
+ - **`customMetric`**: `Optional[Callable]`
142
+ - Description: User-defined metric function for evaluation.
143
+ - Validation:
144
+ - Function must accept `y_true` and `y_pred` as the first two arguments.
145
+ - Must return a scalar value (int or float).
146
+ - Function execution is validated with dummy arguments.
147
+ - Default: `None`
148
+
149
+ #### Custom Preprocessors:
150
+ - **`customImputerNum`**: `Optional[Any]`
151
+ - Description: Custom numeric data imputer.
152
+ - Validation:
153
+ - Must be an object with `fit`, `transform`, and optionally `fit_transform` methods.
154
+ - Validated with dummy data.
155
+ - Default: `None`
156
+
157
+ - **`customImputerCat`**: `Optional[Any]`
158
+ - Description: Custom categorical data imputer.
159
+ - Validation:
160
+ - Must be an object with `fit`, `transform`, and optionally `fit_transform` methods.
161
+ - Validated with dummy data.
162
+ - Default: `None`
163
+
164
+ ## Functions:
165
+
166
+ ### **`fit`**
167
+ ```python
168
+ fit(self, X, y, test_size=0.4, showTable=True)
169
+ ```
170
+ Fits classification algorithms to `X` and `y` using a hold-out approach. Predicts and scores on a test set determined by `test_size`.
171
+
172
+ #### Parameters:
173
+ - **`X`**: Input features (DataFrame or compatible format).
174
+ - **`y`**: Target labels (must be numeric, e.g., via `LabelEncoder` or `OrdinalEncoder`).
175
+ - **`test_size`**: Proportion of the dataset to use as the test set. Default is `0.4`.
176
+ - **`showTable`**: Display a table with results. Default is `True`.
177
+
178
+ #### Behavior:
179
+ - Validates the compatibility of input dimensions.
180
+ - Automatically applies PCA transformation for incompatible dimensions.
181
+ - Requires all categories to be present in training data.
182
+
183
+ ### **`repeated_cross_validation`**
184
+ ```python
185
+ repeated_cross_validation(self, X, y, n_splits=10, n_repeats=5, showTable=True)
186
+ ```
187
+ Performs repeated cross-validation on the dataset using the specified splits and repeats.
188
+
189
+ #### Parameters:
190
+ - **`X`**: Input features (DataFrame or compatible format).
191
+ - **`y`**: Target labels (must be numeric).
192
+ - **`n_splits`**: Number of folds for splitting the dataset. Default is `10`.
193
+ - **`n_repeats`**: Number of times cross-validation is repeated. Default is `5`.
194
+ - **`showTable`**: Display a table with results. Default is `True`.
195
+
196
+ #### Behavior:
197
+ - Uses `RepeatedStratifiedKFold` for generating splits.
198
+ - Aggregates results from multiple train-test splits.
199
+
200
+ ### **`leave_one_out`**
201
+ ```python
202
+ leave_one_out(self, X, y, showTable=True)
203
+ ```
204
+ Performs leave-one-out cross-validation on the dataset.
205
+
206
+ #### Parameters:
207
+ - **`X`**: Input features (DataFrame or compatible format).
208
+ - **`y`**: Target labels (must be numeric).
209
+ - **`showTable`**: Display a table with results. Default is `True`.
210
+
211
+ #### Behavior:
212
+ - Uses `LeaveOneOut` for generating train-test splits.
213
+ - Evaluates the model on each split and aggregates results.
214
+
215
+
216
+
@@ -2,4 +2,4 @@
2
2
 
3
3
  __author__ = """Diego García Vega, Fernando Álvaro Plou Llorente, Alejandro Leal Castaño"""
4
4
  __email__ = "garciavdiego@uniovi.es, ploufernando@uniovi.es, lealcalejandro@uniovi.es"
5
- __version__ = "3.0.5"
5
+ __version__ = "3.0.6"