Quantum Machine Learning Part 2

Classical machine learning algorithms can recognize patterns efficiently. These algorithms are not suitable for all problems. Quantum machine learning algorithms translate machine learning methods into algorithms. Algorithms are based on the building blocks of quantum information processing. It is an emerging discipline combining quantum computing with intelligent data mining. This field is growing with the number of proposals for quantum algorithms. How a quantum computer could enhance methods known from machine learning is the interesting question. One of the problems to be solved in quantum machine learning is the limitation present in the quantity of input data that the proposed implementations can handle.

These algorithms solve the problem of supervised pattern recognition. A dataset of labelled inputs or feature vectors is given in supervised learning. The supervised learning algorithm predicts the label of a new feature vector. Quantum machine learning algorithms based on distance can implement nontrivial circuits. These algorithms are used in supervised and unsupervised learning. Quantum algorithms for k-nearest neighbor and clustering are based on amplitude amplification. Quantum kernel methods such as support vector machines and Gaussian processes  are based on the technical routines for quantum matrix inversion or density matrix exponentiation. Variational quantum classification is a paradigm of supervised quantum machine learning.

Quantum Classifiers

QClassify implements variational quantum classifiers in python. The QClassify framework provides API for performing classification tasks. These tasks use gate model quantum devices. These devices can be either simulated by a simulator or a cloud-based quantum processor.

The quantum classification circuit consists of a single Hadamard gate and two single qubit measurements. These qubit measurements act on an ancilla and a designated class qubit. Quantum routines are used to encode data in amplitudes. QClassifier has abstract information about the classifier to obtain a concrete circuit. QClassify object encapsulates the information in the components. QClassify framework maximizes customization. A specific classification task has subroutines that suit the particular problem setting.


  1. You need to set up Python3.5 to run the code samples below. You can download from this link.

Code sample- quantum_classifier.py:

import qclassify
from qclassify.preprocessing import *
from qclassify.encoding_circ import *
from qclassify.qclassifier import QClassifier
from qclassify.proc_circ import *
from qclassify.postprocessing import *
#encode options
# processor options
#chosen qubits
qubits_chosen = [0, 1] 
# classifier options
classifier_options = {
# QClassifier object encapsulates quits chosen and classifier option in the components. 
quantumCircuit = QClassifier(qubits_chosen, classifier_options)
#input vector and parameters are initialized
input_vector = [1, 1] 
parameters = [3.0672044712460114,          3.3311348339721203] 
#The quantum classifier has circuit method which takes input vector and parameters as input
#The method returns a classification output. 
qc_program = quantumCircuit.circuit(input_vector, parameters) 

Instructions for Running the Code

pip install qclassify
python quantum_classifier.py