groentelepel / qiskit-quantum-knn Goto Github PK
View Code? Open in Web Editor NEWA pure quantum knn classifier for a gated quantum computer.
License: Apache License 2.0
A pure quantum knn classifier for a gated quantum computer.
License: Apache License 2.0
When computing fidelities/contrasts, there is a step where we map the states of the computational basis (e.g. '10010101') back to integers using
index_state = int(comp_state, 2)
However, I read in the documentation of Qiskit that the ordering they use for tensor product states is the opposite of most physics textbooks:
When representing the state of a multi-qubit system, the tensor order used in Qiskit is different than that used in most physics textbooks. Suppose there are π qubits, and qubit π is labeled as ππ. Qiskit uses an ordering in which the πth qubit is on the left side of the tensor product, so that the basis vectors are labeled as ππβ1ββ―βπ1βπ0.
For example, if qubit zero is in state 0, qubit 1 is in state 0, and qubit 2 is in state 1, Qiskit would represent this state as |100β©, whereas many physics textbooks would represent it as |001β©.
I think this means we might have to change the code to
index_state = int(comp_state[::-1], 2)
I played around with this a little bit in a juptyer notebook, where I tried to explicitly compute the fidelities of some sample states, and found that without this change, a lot of them get swapped around. Reversing the order as above seems to fix the issue.
If what I'm saying is correct, we'd have to make 2 changes:
Running the QKneighborsClassifier
using
n_variables = 4
n_train_points = 4
n_test_points = 1
Results in an error:
File "qiskit_quantum_knn/qknn/qkneighborsclassifier.py", line 266, in get_all_contrasts
num_qubits = len(list(all_counts[0].keys())[0]) - 2
KeyError: 0
Since the qiskit aqua is depricated now, this code is not working anymore. Can somebody please help me in implementing this QKNN with latest qiskit libraries.
Hello !
It would be great if you released a new patched version so that your library can be easily accessed.
Now it doesn't work because of aqua.
Have a nice day!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.