1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
%global _empty_manifest_terminate_build 0
Name: python-qiskit-machine-learning
Version: 0.6.1
Release: 1
Summary: Qiskit Machine Learning: A library of quantum computing machine learning experiments
License: Apache-2.0
URL: https://github.com/Qiskit/qiskit-machine-learning
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/09/c6/502e29169953df4a7c3f8539858d3546877198bf7cafa6318361d5d381c4/qiskit-machine-learning-0.6.1.tar.gz
BuildArch: noarch
Requires: python3-qiskit-terra
Requires: python3-scipy
Requires: python3-numpy
Requires: python3-psutil
Requires: python3-scikit-learn
Requires: python3-fastdtw
Requires: python3-setuptools
Requires: python3-dill
Requires: python3-sparse
Requires: python3-torch
%description
### Optional Installs
* **PyTorch**, may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the
package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). When PyTorch
is installed, the `TorchConnector` facilitates its use of quantum computed networks.
* **Sparse**, may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the
package. Sparse being installed will enable the usage of sparse arrays/tensors.
### Creating Your First Machine Learning Programming Experiment in Qiskit
Now that Qiskit Machine Learning is installed, it's time to begin working with the Machine Learning module.
Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to
train and test samples from a data set to see how accurately the test set can
be classified.
```python
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import TwoLocal, ZZFeatureMap
from qiskit.utils import algorithm_globals
from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.datasets import ad_hoc_data
seed = 1376
algorithm_globals.random_seed = seed
# Use ad hoc data set for training and test data
feature_dim = 2 # dimension of each data point
training_size = 20
test_size = 10
# training features, training labels, test features, test labels as np.ndarray,
# one hot encoding for labels
training_features, training_labels, test_features, test_labels = ad_hoc_data(
training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3
)
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement="linear")
ansatz = TwoLocal(feature_map.num_qubits, ["ry", "rz"], "cz", reps=3)
vqc = VQC(
feature_map=feature_map,
ansatz=ansatz,
optimizer=COBYLA(maxiter=100),
)
vqc.fit(training_features, training_labels)
score = vqc.score(test_features, test_labels)
print(f"Testing accuracy: {score:0.2f}")
```
### Further examples
Learning path notebooks may be found in the
[Machine Learning tutorials](https://qiskit.org/documentation/machine-learning/tutorials/index.html) section
of the documentation and are a great place to start.
Another good place to learn the fundamentals of quantum machine learning is the
[Quantum Machine Learning](https://learn.qiskit.org/course/machine-learning/introduction) course
on the Qiskit Textbook's website. The course is very convenient for beginners who are eager to learn
quantum machine learning from scratch, as well as understand the background and theory behind algorithms in
Qiskit Machine Learning. The course covers a variety of topics to build understanding of parameterized
circuits, data encoding, variational algorithms etc., and in the end the ultimate goal of machine
learning - how to build and train quantum ML models for supervised and unsupervised learning.
The textbook course is complementary to the tutorials of this module, where the tutorials focus
on actual Qiskit Machine Learning algorithms, the course more explains and details underlying fundamentals
%package -n python3-qiskit-machine-learning
Summary: Qiskit Machine Learning: A library of quantum computing machine learning experiments
Provides: python-qiskit-machine-learning
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-qiskit-machine-learning
### Optional Installs
* **PyTorch**, may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the
package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). When PyTorch
is installed, the `TorchConnector` facilitates its use of quantum computed networks.
* **Sparse**, may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the
package. Sparse being installed will enable the usage of sparse arrays/tensors.
### Creating Your First Machine Learning Programming Experiment in Qiskit
Now that Qiskit Machine Learning is installed, it's time to begin working with the Machine Learning module.
Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to
train and test samples from a data set to see how accurately the test set can
be classified.
```python
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import TwoLocal, ZZFeatureMap
from qiskit.utils import algorithm_globals
from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.datasets import ad_hoc_data
seed = 1376
algorithm_globals.random_seed = seed
# Use ad hoc data set for training and test data
feature_dim = 2 # dimension of each data point
training_size = 20
test_size = 10
# training features, training labels, test features, test labels as np.ndarray,
# one hot encoding for labels
training_features, training_labels, test_features, test_labels = ad_hoc_data(
training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3
)
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement="linear")
ansatz = TwoLocal(feature_map.num_qubits, ["ry", "rz"], "cz", reps=3)
vqc = VQC(
feature_map=feature_map,
ansatz=ansatz,
optimizer=COBYLA(maxiter=100),
)
vqc.fit(training_features, training_labels)
score = vqc.score(test_features, test_labels)
print(f"Testing accuracy: {score:0.2f}")
```
### Further examples
Learning path notebooks may be found in the
[Machine Learning tutorials](https://qiskit.org/documentation/machine-learning/tutorials/index.html) section
of the documentation and are a great place to start.
Another good place to learn the fundamentals of quantum machine learning is the
[Quantum Machine Learning](https://learn.qiskit.org/course/machine-learning/introduction) course
on the Qiskit Textbook's website. The course is very convenient for beginners who are eager to learn
quantum machine learning from scratch, as well as understand the background and theory behind algorithms in
Qiskit Machine Learning. The course covers a variety of topics to build understanding of parameterized
circuits, data encoding, variational algorithms etc., and in the end the ultimate goal of machine
learning - how to build and train quantum ML models for supervised and unsupervised learning.
The textbook course is complementary to the tutorials of this module, where the tutorials focus
on actual Qiskit Machine Learning algorithms, the course more explains and details underlying fundamentals
%package help
Summary: Development documents and examples for qiskit-machine-learning
Provides: python3-qiskit-machine-learning-doc
%description help
### Optional Installs
* **PyTorch**, may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the
package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). When PyTorch
is installed, the `TorchConnector` facilitates its use of quantum computed networks.
* **Sparse**, may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the
package. Sparse being installed will enable the usage of sparse arrays/tensors.
### Creating Your First Machine Learning Programming Experiment in Qiskit
Now that Qiskit Machine Learning is installed, it's time to begin working with the Machine Learning module.
Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to
train and test samples from a data set to see how accurately the test set can
be classified.
```python
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import TwoLocal, ZZFeatureMap
from qiskit.utils import algorithm_globals
from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.datasets import ad_hoc_data
seed = 1376
algorithm_globals.random_seed = seed
# Use ad hoc data set for training and test data
feature_dim = 2 # dimension of each data point
training_size = 20
test_size = 10
# training features, training labels, test features, test labels as np.ndarray,
# one hot encoding for labels
training_features, training_labels, test_features, test_labels = ad_hoc_data(
training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3
)
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement="linear")
ansatz = TwoLocal(feature_map.num_qubits, ["ry", "rz"], "cz", reps=3)
vqc = VQC(
feature_map=feature_map,
ansatz=ansatz,
optimizer=COBYLA(maxiter=100),
)
vqc.fit(training_features, training_labels)
score = vqc.score(test_features, test_labels)
print(f"Testing accuracy: {score:0.2f}")
```
### Further examples
Learning path notebooks may be found in the
[Machine Learning tutorials](https://qiskit.org/documentation/machine-learning/tutorials/index.html) section
of the documentation and are a great place to start.
Another good place to learn the fundamentals of quantum machine learning is the
[Quantum Machine Learning](https://learn.qiskit.org/course/machine-learning/introduction) course
on the Qiskit Textbook's website. The course is very convenient for beginners who are eager to learn
quantum machine learning from scratch, as well as understand the background and theory behind algorithms in
Qiskit Machine Learning. The course covers a variety of topics to build understanding of parameterized
circuits, data encoding, variational algorithms etc., and in the end the ultimate goal of machine
learning - how to build and train quantum ML models for supervised and unsupervised learning.
The textbook course is complementary to the tutorials of this module, where the tutorials focus
on actual Qiskit Machine Learning algorithms, the course more explains and details underlying fundamentals
%prep
%autosetup -n qiskit-machine-learning-0.6.1
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-qiskit-machine-learning -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue May 30 2023 Python_Bot <Python_Bot@openeuler.org> - 0.6.1-1
- Package Spec generated
|