lazyqml 2.0.4__tar.gz → 3.0.0__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.
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/workflows/installation.yml +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/workflows/pypi.yml +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/workflows/ubuntu.yml +1 -1
- lazyqml-3.0.0/LICENSE +21 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/PKG-INFO +43 -30
- lazyqml-2.0.4/README.md → lazyqml-3.0.0/README copy.md +3 -4
- lazyqml-3.0.0/README.md +83 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/AmplitudeEmbedding.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/HCzRx.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/HardwareEfficient.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/RxEmbedding.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/RyEmbedding.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/RzEmbedding.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/TreeTensor.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/TwoLocal.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/ZzEmbedding.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Circuits/fCircuits.py +10 -10
- lazyqml-3.0.0/lazyqml/Factories/Dispatchers/Dispatcher.py +326 -0
- lazyqml-3.0.0/lazyqml/Factories/Models/Hybrid.py +460 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Models/QNNBag.py +6 -6
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Models/QNNTorch.py +8 -8
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Models/QSVM.py +3 -3
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Models/_QNNPennylane.py +4 -4
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Models/fModels.py +4 -4
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Preprocessing/Pca.py +2 -2
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Preprocessing/Sanitizer.py +2 -2
- lazyqml-3.0.0/lazyqml/Factories/Preprocessing/fPreprocessing.py +21 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Global/globalEnums.py +3 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Interfaces/iAnsatz.py +1 -1
- lazyqml-3.0.0/lazyqml/Utils/Utils.py +280 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Utils/Validator.py +4 -7
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/__init__.py +1 -1
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/lazyqml.py +54 -49
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/PKG-INFO +43 -30
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/SOURCES.txt +3 -21
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/requires.txt +1 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/pyproject.toml +6 -8
- lazyqml-3.0.0/requirements.txt +17 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/requirements_dev.txt +2 -1
- lazyqml-3.0.0/tests/test_lazyqml.py +18 -0
- lazyqml-2.0.4/.github/workflows/macos.yml +0 -42
- lazyqml-2.0.4/.github/workflows/windows.yml +0 -34
- lazyqml-2.0.4/lazyqml/.lazyqmlP.py +0 -293
- lazyqml-2.0.4/lazyqml/.lazyqmlVote.py +0 -303
- lazyqml-2.0.4/lazyqml/Factories/Circuits/_Qkernel.py +0 -16
- lazyqml-2.0.4/lazyqml/Factories/Circuits/_Qnn.py +0 -17
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/Dispatcher.py +0 -147
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/DispatcherCV.py +0 -143
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/DispatcherNumba.py +0 -226
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/_Dispatcher.py +0 -188
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/_DispatcherMultiprocessing.py +0 -201
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/_QNNBagdispatcher.py +0 -2
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/_QNNdispatcher.py +0 -2
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/_QSVMdispatcher.py +0 -112
- lazyqml-2.0.4/lazyqml/Factories/Dispatchers/__Dispatcher.py +0 -193
- lazyqml-2.0.4/lazyqml/Factories/Preprocessing/_PcaAmp.py +0 -22
- lazyqml-2.0.4/lazyqml/Factories/Preprocessing/_PcaTree.py +0 -22
- lazyqml-2.0.4/lazyqml/Factories/Preprocessing/_PcaTreeAmp.py +0 -22
- lazyqml-2.0.4/lazyqml/Factories/Preprocessing/fPreprocessing.py +0 -40
- lazyqml-2.0.4/lazyqml/Lanza copy.sh +0 -32
- lazyqml-2.0.4/lazyqml/Lanza.sh +0 -21
- lazyqml-2.0.4/lazyqml/Utils/Utils.py +0 -161
- lazyqml-2.0.4/lazyqml/mem.py +0 -85
- lazyqml-2.0.4/requirements.txt +0 -66
- lazyqml-2.0.4/tests/LazyQML.ipynb +0 -454
- lazyqml-2.0.4/tests/test_lazyqml.py +0 -42
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.editorconfig +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/workflows/docs-build.yml +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.github/workflows/docs.yml +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/.gitignore +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/AUTHORS.rst +0 -0
- /lazyqml-2.0.4/LICENSE → /lazyqml-3.0.0/LICENSE copy +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/MANIFEST.in +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/authors.rst +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/changelog.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/common.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/contributing.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/examples/intro.ipynb +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/faq.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/index.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/installation.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/lazyqml.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/overrides/main.html +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/docs/usage.md +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/experimentallibs.txt +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/Preprocessing/__init__.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Factories/__init__.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Interfaces/__init__.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Interfaces/iCircuit.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Interfaces/iModel.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml/Interfaces/iPreprocessing.py +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/dependency_links.txt +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/entry_points.txt +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/lazyqml.egg-info/top_level.txt +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/mkdocs.yml +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/setup.cfg +0 -0
- {lazyqml-2.0.4 → lazyqml-3.0.0}/tests/__init__.py +0 -0
lazyqml-3.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 QHPC & SP Research Lab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lazyqml
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: LazyQML benchmarking utility to test quantum machine learning models.
|
|
5
|
-
Author-email:
|
|
5
|
+
Author-email: QHPC Group <qhpcgroup@gmail.com>
|
|
6
6
|
License: MIT License
|
|
7
|
-
Project-URL: Homepage, https://github.com/
|
|
7
|
+
Project-URL: Homepage, https://github.com/QHPC-SP-Research-Lab/LazyQML
|
|
8
8
|
Keywords: lazyqml
|
|
9
9
|
Classifier: Intended Audience :: Science/Research
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Natural Language :: English
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.
|
|
13
|
-
Requires-Python: >=3.
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
+
License-File: LICENSE copy
|
|
16
17
|
License-File: AUTHORS.rst
|
|
17
18
|
Requires-Dist: wheel
|
|
18
19
|
Requires-Dist: tabulate
|
|
@@ -30,6 +31,7 @@ Requires-Dist: pydantic
|
|
|
30
31
|
Requires-Dist: psutil
|
|
31
32
|
Requires-Dist: pandas
|
|
32
33
|
Requires-Dist: joblib
|
|
34
|
+
Requires-Dist: gputil
|
|
33
35
|
Provides-Extra: all
|
|
34
36
|
Requires-Dist: lazyqml[extra]; extra == "all"
|
|
35
37
|
Provides-Extra: extra
|
|
@@ -38,20 +40,51 @@ Requires-Dist: pandas; extra == "extra"
|
|
|
38
40
|
# LazyQML
|
|
39
41
|
|
|
40
42
|
|
|
41
|
-
[](https://pypi.python.org/pypi/lazyqml)
|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+

|
|
48
|
+

|
|
49
|
+

|
|
50
|
+
<img src="https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg" alt="Pennylane Logo" style="background-color: white; padding: 2px;" />
|
|
51
|
+

|
|
42
52
|
|
|
53
|
+
<!--  -->
|
|
43
54
|
|
|
44
|
-
|
|
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
|
+
## Usage
|
|
57
|
+
```python
|
|
58
|
+
from lazyqml.lazyqml import QuantumClassifier
|
|
59
|
+
from lazyqml.Global.globalEnums import *
|
|
60
|
+
from sklearn.datasets import load_breast_cancer, load_iris
|
|
61
|
+
from sklearn.model_selection import train_test_split
|
|
62
|
+
# Load data
|
|
63
|
+
data = load_iris()
|
|
64
|
+
X = data.data
|
|
65
|
+
y = data.target
|
|
45
66
|
|
|
67
|
+
# Split data
|
|
68
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=.3,random_state =123)
|
|
69
|
+
|
|
70
|
+
# Initialize L azyClass ifier
|
|
71
|
+
classifier = QuantumClassifier(nqubits={4,8,16},verbose=True,sequential=False,backend=Backend.lightningQubit)
|
|
72
|
+
|
|
73
|
+
# Fit and predict
|
|
74
|
+
classifier.fit(X_train=X_train,y_train=y_train,X_test=X_test,y_test=y_test)
|
|
75
|
+
```
|
|
46
76
|
|
|
77
|
+
## License & Compatibility
|
|
47
78
|
- Free software: MIT License
|
|
79
|
+
- This Python package is only compatible with Linux systems.
|
|
80
|
+
- Hardware acceleration is only enabled using CUDA-compatible devices.
|
|
48
81
|
## Quantum and High Performance Computing (QHPC) - University of Oviedo
|
|
49
82
|
- José Ranilla Pastor - ranilla@uniovi.es
|
|
50
83
|
- Elías Fernández Combarro - efernandezca@uniovi.es
|
|
51
|
-
- Diego García Vega -
|
|
84
|
+
- Diego García Vega - diegogarciavega@gmail.com
|
|
52
85
|
- Fernando Álvaro Plou Llorente - ploufernando@uniovi.es
|
|
53
86
|
- Alejandro Leal Castaño - lealcalejandro@uniovi.es
|
|
54
|
-
- Group - https://qhpc.
|
|
87
|
+
- Group - https://qhpc.uniovi.es
|
|
55
88
|
|
|
56
89
|
## Parameters:
|
|
57
90
|
- **verbose** _bool, optional (default=False)_: If set to True, detailed messages about the training process will be displayed, helping users to monitor the progress and debug if necessary.
|
|
@@ -75,7 +108,7 @@ Requires-Dist: pandas; extra == "extra"
|
|
|
75
108
|
- **threshold** _int, optional (default=22)_: Integer value used to delimit from which number of qubits the internal operations of the models start to be parallelized. This helps optimize performance for larger quantum circuits.
|
|
76
109
|
- **cores** _int, optional (default=-1)_: Number of processes to be created by the dispatcher to run the selected models. Each process will be allocated as many CPU cores as possible for parallel execution.
|
|
77
110
|
## Functions:
|
|
78
|
-
- **fit** _(
|
|
111
|
+
- **fit** _(X, y, test\_size, showTable=True)_: Fit Classification algorithms to X and y using hold-out, predict and score on test set (test_size).
|
|
79
112
|
If the dimensions of the training vectors are not compatible with the different models, a
|
|
80
113
|
PCA transformation will be used in order to reduce the dimensionality to a compatible space.
|
|
81
114
|
All categories must be in the training data if there are new categories in the test date the
|
|
@@ -86,24 +119,4 @@ Requires-Dist: pandas; extra == "extra"
|
|
|
86
119
|
|
|
87
120
|
- **leave_one_out** _(X, y, showTable=True)_: Perform leave-one-out cross-validation on the given dataset and model. This method splits the dataset into multiple train-test splits using LeaveOneOut,
|
|
88
121
|
fits the model on the training set, evaluates it on the validation set, and aggregates the results.
|
|
89
|
-
- **glue_hybrid** _(X,y,model,showTable=True)_:This function takes both the training and test data, along with a user-provided torch model. It connects the given model to a fully connected layer, which acts as a bridge between the classical neural network and the selected Quantum Neural Networks (QNNs). The combined model is then used to train on the data and make predictions on the test set, leveraging the strengths of both classical and quantum approaches.
|
|
90
|
-
## Usage:
|
|
91
|
-
```python
|
|
92
|
-
from lazyqml.lazyqml import QuantumClassifier
|
|
93
|
-
from lazyqml.Global.globalEnums import *
|
|
94
|
-
from sklearn.datasets import load_breast_cancer, load_iris
|
|
95
|
-
from sklearn.model_selection import train_test_split
|
|
96
|
-
# Load data
|
|
97
|
-
data = load_iris()
|
|
98
|
-
X = data.data
|
|
99
|
-
y = data.target
|
|
100
122
|
|
|
101
|
-
# Split data
|
|
102
|
-
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=.3,random_state =123)
|
|
103
|
-
|
|
104
|
-
# Initialize L azyClass ifier
|
|
105
|
-
classifier = QuantumClassifier(nqubits={4,8,16},verbose=True,sequential=False,backend=Backend.lightningQubit)
|
|
106
|
-
|
|
107
|
-
# Fit and predict
|
|
108
|
-
classifier.fit(X_train=X_train,y_train=y_train,X_test=X_test,y_test=y_test)
|
|
109
|
-
```
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
## Quantum and High Performance Computing (QHPC) - University of Oviedo
|
|
12
12
|
- José Ranilla Pastor - ranilla@uniovi.es
|
|
13
13
|
- Elías Fernández Combarro - efernandezca@uniovi.es
|
|
14
|
-
- Diego García Vega -
|
|
14
|
+
- Diego García Vega - diegogarciavega@gmail.com
|
|
15
15
|
- Fernando Álvaro Plou Llorente - ploufernando@uniovi.es
|
|
16
16
|
- Alejandro Leal Castaño - lealcalejandro@uniovi.es
|
|
17
|
-
- Group - https://qhpc.
|
|
17
|
+
- Group - https://qhpc.uniovi.es
|
|
18
18
|
|
|
19
19
|
## Parameters:
|
|
20
20
|
- **verbose** _bool, optional (default=False)_: If set to True, detailed messages about the training process will be displayed, helping users to monitor the progress and debug if necessary.
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
- **threshold** _int, optional (default=22)_: Integer value used to delimit from which number of qubits the internal operations of the models start to be parallelized. This helps optimize performance for larger quantum circuits.
|
|
39
39
|
- **cores** _int, optional (default=-1)_: Number of processes to be created by the dispatcher to run the selected models. Each process will be allocated as many CPU cores as possible for parallel execution.
|
|
40
40
|
## Functions:
|
|
41
|
-
- **fit** _(
|
|
41
|
+
- **fit** _(X, y, test\_size, showTable=True)_: Fit Classification algorithms to X and y using hold-out, predict and score on test set (test_size).
|
|
42
42
|
If the dimensions of the training vectors are not compatible with the different models, a
|
|
43
43
|
PCA transformation will be used in order to reduce the dimensionality to a compatible space.
|
|
44
44
|
All categories must be in the training data if there are new categories in the test date the
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
|
|
50
50
|
- **leave_one_out** _(X, y, showTable=True)_: Perform leave-one-out cross-validation on the given dataset and model. This method splits the dataset into multiple train-test splits using LeaveOneOut,
|
|
51
51
|
fits the model on the training set, evaluates it on the validation set, and aggregates the results.
|
|
52
|
-
- **glue_hybrid** _(X,y,model,showTable=True)_:This function takes both the training and test data, along with a user-provided torch model. It connects the given model to a fully connected layer, which acts as a bridge between the classical neural network and the selected Quantum Neural Networks (QNNs). The combined model is then used to train on the data and make predictions on the test set, leveraging the strengths of both classical and quantum approaches.
|
|
53
52
|
## Usage:
|
|
54
53
|
```python
|
|
55
54
|
from lazyqml.lazyqml import QuantumClassifier
|
lazyqml-3.0.0/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# LazyQML
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[](https://pypi.python.org/pypi/lazyqml)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
<img src="https://assets.cloud.pennylane.ai/pennylane_website/generic/logo.svg" alt="Pennylane Logo" style="background-color: white; padding: 2px;" />
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
<!--  -->
|
|
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
|
+
## Usage
|
|
18
|
+
```python
|
|
19
|
+
from lazyqml.lazyqml import QuantumClassifier
|
|
20
|
+
from lazyqml.Global.globalEnums import *
|
|
21
|
+
from sklearn.datasets import load_breast_cancer, load_iris
|
|
22
|
+
from sklearn.model_selection import train_test_split
|
|
23
|
+
# Load data
|
|
24
|
+
data = load_iris()
|
|
25
|
+
X = data.data
|
|
26
|
+
y = data.target
|
|
27
|
+
|
|
28
|
+
# Split data
|
|
29
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=.3,random_state =123)
|
|
30
|
+
|
|
31
|
+
# Initialize L azyClass ifier
|
|
32
|
+
classifier = QuantumClassifier(nqubits={4,8,16},verbose=True,sequential=False,backend=Backend.lightningQubit)
|
|
33
|
+
|
|
34
|
+
# Fit and predict
|
|
35
|
+
classifier.fit(X_train=X_train,y_train=y_train,X_test=X_test,y_test=y_test)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License & Compatibility
|
|
39
|
+
- Free software: MIT License
|
|
40
|
+
- This Python package is only compatible with Linux systems.
|
|
41
|
+
- Hardware acceleration is only enabled using CUDA-compatible devices.
|
|
42
|
+
## Quantum and High Performance Computing (QHPC) - University of Oviedo
|
|
43
|
+
- José Ranilla Pastor - ranilla@uniovi.es
|
|
44
|
+
- Elías Fernández Combarro - efernandezca@uniovi.es
|
|
45
|
+
- Diego García Vega - diegogarciavega@gmail.com
|
|
46
|
+
- Fernando Álvaro Plou Llorente - ploufernando@uniovi.es
|
|
47
|
+
- Alejandro Leal Castaño - lealcalejandro@uniovi.es
|
|
48
|
+
- Group - https://qhpc.uniovi.es
|
|
49
|
+
|
|
50
|
+
## Parameters:
|
|
51
|
+
- **verbose** _bool, optional (default=False)_: If set to True, detailed messages about the training process will be displayed, helping users to monitor the progress and debug if necessary.
|
|
52
|
+
- **customMetric** _function, optional (default=None)_: A custom evaluation function provided by the user to evaluate the models. This allows the user to define their own metrics tailored to specific requirements.
|
|
53
|
+
- **customImputerNum** _function, optional (default=None)_: A custom function provided by the user to handle the imputation of missing numeric data. This provides flexibility in how missing values are treated in the dataset.
|
|
54
|
+
- **customImputerCat** _function, optional (default=None)_: A custom function provided by the user to handle the imputation of missing categorical data, allowing users to apply their own strategies for handling missing categorical values.
|
|
55
|
+
- **prediction** _bool, optional (default=False)_: If set to True, the predictions made by all the models will be returned as a pandas DataFrame for easy comparison and analysis of different models’ outputs.
|
|
56
|
+
- **classifiers** _set of enums, optional (default={Model.ALL})_: A set specifying which classifiers to train. Options include `{Model.ALL, Model.QSVM, Model.QNN, Model.QNN_BAG}`, enabling the user to select specific quantum classifiers or train all available ones.
|
|
57
|
+
- **embeddings** _set of enums, optional (default={Embedding.ALL})_: A set specifying which embeddings to use for training. Options include `{Embedding.ALL, Embedding.RX, Embedding.RZ, Embedding.RY, Embedding.ZZ, Embedding.AMP}`, allowing the user to choose specific data encodings.
|
|
58
|
+
- **ansatzs** _set of enums, optional (default={Ansatzs.ALL})_: A set specifying which quantum circuit ansatzes to use. Options include `{Ansatzs.ALL, Ansatzs.HCZRX, Ansatzs.TREE_TENSOR, Ansatzs.TWO_LOCAL, Ansatzs.HARDWARE_EFFICIENT}`, giving users the ability to experiment with different quantum circuit structures.
|
|
59
|
+
- **randomState** _int, optional (default=1234)_: An integer seed used to ensure the repeatability of experiments, making the results consistent across different runs.
|
|
60
|
+
- **nqubits** _int, optional (default=8)_: Specifies the number of qubits for the quantum circuits used by the models. This parameter controls the size of the quantum circuits.
|
|
61
|
+
- **numLayers** _int, optional (default=5)_: Indicates the number of layers in the Quantum Neural Network (QNN) models, affecting the depth and potentially the performance of the neural networks.
|
|
62
|
+
- **numPredictors** _int, optional (default=10)_: Specifies the number of different predictors used in Quantum Neural Networks with Bagging (QNN_Bag). This parameter controls the ensemble size in bagging models.
|
|
63
|
+
- **maxSamples** _float, optional (default=1.0)_: A floating point number between 0 and 1.0 indicating the fraction of the dataset to be used for each Quantum Neural Network with Bagging (QNN_Bag).
|
|
64
|
+
- **maxFeatures** _float, optional (default=0.8)_: A floating point number between 0 and 1.0 indicating the fraction of the dataset features to be used for each Quantum Neural Network with Bagging (QNN_Bag).
|
|
65
|
+
- **runs** _int, optional (default=1)_: The number of training runs for the Quantum Neural Network (QNN) models. This parameter determines how many times the model is trained and evaluated.
|
|
66
|
+
- **learningRate** _float, optional (default=0.01)_: The learning rate for the gradient descent optimization process used in all Quantum Neural Networks (QNNs). This controls how much the model's weights are updated during each training step.
|
|
67
|
+
- **epochs** _int, optional (default=100)_: The number of complete passes through the dataset during model fitting. More epochs can allow the model to converge more accurately, though may increase computation time.
|
|
68
|
+
- **backend** _enum, optional (default=Backend.lightningQubit)_: This field controls the acceleration used in the quantum simulator. Supported values are `{Backend.lightningQubit, Backend.lightningGPU, Backend.defaultQubit}`, specifying which backend to use for quantum circuit simulation.
|
|
69
|
+
- **threshold** _int, optional (default=22)_: Integer value used to delimit from which number of qubits the internal operations of the models start to be parallelized. This helps optimize performance for larger quantum circuits.
|
|
70
|
+
- **cores** _int, optional (default=-1)_: Number of processes to be created by the dispatcher to run the selected models. Each process will be allocated as many CPU cores as possible for parallel execution.
|
|
71
|
+
## Functions:
|
|
72
|
+
- **fit** _(X, y, test\_size, showTable=True)_: Fit Classification algorithms to X and y using hold-out, predict and score on test set (test_size).
|
|
73
|
+
If the dimensions of the training vectors are not compatible with the different models, a
|
|
74
|
+
PCA transformation will be used in order to reduce the dimensionality to a compatible space.
|
|
75
|
+
All categories must be in the training data if there are new categories in the test date the
|
|
76
|
+
function will not work. The objective variable must be in a numerical form like LabelEncoder or
|
|
77
|
+
OrdinalEncoder. Onehot or strings won't work.
|
|
78
|
+
- **repeated_cross_validation** _(X, y, n_splits=5, n_repeats=10, showTable=True)_: Perform repeated cross-validation on the given dataset and model.This method splits the dataset into multiple train-test splits using RepeatedStratifiedKFold,
|
|
79
|
+
fits the model on the training set, evaluates it on the validation set, and aggregates the results.
|
|
80
|
+
|
|
81
|
+
- **leave_one_out** _(X, y, showTable=True)_: Perform leave-one-out cross-validation on the given dataset and model. This method splits the dataset into multiple train-test splits using LeaveOneOut,
|
|
82
|
+
fits the model on the training set, evaluates it on the validation set, and aggregates the results.
|
|
83
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Importing Enums
|
|
2
|
-
from
|
|
2
|
+
from Global.globalEnums import Ansatzs, Embedding
|
|
3
3
|
# Importing Ansatzs
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from Factories.Circuits.TwoLocal import *
|
|
5
|
+
from Factories.Circuits.HardwareEfficient import *
|
|
6
|
+
from Factories.Circuits.TreeTensor import *
|
|
7
|
+
from Factories.Circuits.HCzRx import *
|
|
8
8
|
# Importing Embeddings
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
9
|
+
from Factories.Circuits.RxEmbedding import *
|
|
10
|
+
from Factories.Circuits.RyEmbedding import *
|
|
11
|
+
from Factories.Circuits.RzEmbedding import *
|
|
12
|
+
from Factories.Circuits.ZzEmbedding import *
|
|
13
|
+
from Factories.Circuits.AmplitudeEmbedding import *
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class CircuitFactory:
|