<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Quantum Algorithm for Ensemble Learning ?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Antonio Macaluso</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefano Lodi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Claudio Sartori</string-name>
          <email>claudio.sartorig@unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dept. of Computer Science and Engineering, University of Bologna</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>The idea of ensemble learning is to build a prediction model by combining the strengths of a collection of simpler base models. Although they are extensively used, ensemble methods have high requirements in terms of memory and computational time. In this work, we propose a quantum algorithm that allows reproducing ensemble classi cation using bagging strategy. The algorithm generates many sub-samples in superposition, in such a way that only a single execution of a quantum classi er is required. In particular, the entanglement between a quantum register and di erent training sub-samples in superposition allows obtaining a sum of individual results which gives rise to the ensemble prediction. When considering the overall temporal cost of the algorithm, the single base classi er impacts additively rather than multiplicatively, as it usually happens in ensemble framework. Furthermore, given that the number of base models scales exponentially with the number of qubits of the control register, our algorithm opens up the possibility of exponential speed-up for quantum ensemble.</p>
      </abstract>
      <kwd-group>
        <kwd>Quantum Computing Machine Learning Ensemble Methods</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Thanks to the quantum mechanical principles of superposition and
entanglement, Quantum Computing (QC) can achieve vast amounts of parallelism [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]
without the need for the multiple replications of hardware that are usually
required in a classical computer. One of the most important elds in which QC
promises to make an impact in the future is machine learning (ML). However,
being an entirely new eld, Quantum Machine Learning (QML) poses many
open challenges [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>
        The idea of a quantum ensemble based on Bayesian Model Averaging (BMA)
is investigated in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], but BMA approach is not very used in ML because of its
limited performance in real-world applications [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>
        In general, the idea of ensemble learning is to build a prediction model by
combining the strengths of a collection of simpler base models to reduce the
Expected Prediction Error [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. One of the most popular schemas to build an
? Copyright c 2020 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).
ensemble is Bagging, in which a committee of independent weak classi ers cast
a vote for the predicted class. It is the basis of the well-known method
Random Forest [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] and constructs a homogeneous ensemble by applying the same
learning algorithm under di erent training conditions. In practice, we compute
f1(x); : : : ; fB(x) using B separate training sets and average them to obtain a
single low-variance model:
fbag(x) =
1 B
      </p>
      <p>
        X fb(x):
B
b=1
It turns out that Bagging produces a combined model that outperforms the
single model built from all training data, and is never substantially worse [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Contribution</title>
      <p>In this work, we provide a quantum algorithm to perform ensemble classi cation
using bagging. The idea is to generate di erent sub-samples of the training set in
superposition, each entangled with a quantum state of a control register. Thus,
a quantum classi er C is applied to obtain a large number of classi cations in
superposition. The proposed algorithm limits the number of state preparation
routines and makes the evaluation of large ensemble feasible with small circuits.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Quantum Algorithm for Bagging Ensemble</title>
      <p>The quantum algorithm for ensemble involves 5 quantum registers:
j 0i =</p>
      <p>j0i
control</p>
      <p>j0i
training
j0i
temp
j0i
test</p>
      <p>j0i
target
where the size of the control register determines the size of the ensemble (i.e.
the number of base models), the size of training and test registers depend on
the amount of data. The temp register determines the size of the sub-sample
used as input in a single base model. Finally, the number of qubits in the target
register depends on the nature of the target variable. Starting from these ve
registers, the algorithm involves four steps:
(Step 1) The state preparation consists in encoding the training and test set
into their respective registers. Also, the control register is initialised into uniform
superposition:
j 1i =
=</p>
      <p>H d</p>
      <p>S(x;y)
1 X2d jii
p2d i=1
!
1</p>
      <p>S(x~)</p>
      <p>1 j 0i =
jx; yi
j0i
jx~i
where S(x;y) and S(x~) are the unitaries that encode data in quantum states
whose form depends on the encoding strategy chosen for data, and H d is the
Walsh-Hadamard gate.
(1)
(2)
(Step 2) The second step is sampling in superposition and consists in generating
many altered transformation of the original training data, (x; y), in
superposition. We consider a quantum oracle V which entangles several sub-sample of
data with the control register:
j 2i = V
1
1 j 1i =</p>
      <p>1 X2d jii jx; yi jxi; yii
p2d i=1
!
jx~i
(3)
where jxi; yii is a random sub-sample of jx; yi. After this step, the training
register can be in any state, it will not be used further in the computation.
(Step 3) The classi cation step consists in the interaction via interference
between the temp and test registers, to store the estimates of the target variable:</p>
      <p>C j 2i = p12d Xi2=d1 jii jx; yi jxi; yii jx~i jfi(x~)i ;
(4)
where fi(x~) is an estimate of the target variable for x~ and it depends on the i-th
sub-sample and the test set x~. We refer to C as a quantum oracle that takes
as input two sets of data encoded into two di erent registers, and provides an
estimate of the target variable in an additional register.
(Step 4) Finally, the expectation measurement on the target qubit provides a
sum of expectation values that corresponds to the ensemble prediction:
hM i =
=</p>
      <p>3j1 d 1 1 1 M 3 =
21d Xi2=d1 hfi(x~)jM jfi(x~)i = 21d Xi2=d0 hMii = B1 Xb=B1 fb = fbag x~j(x; y)
(5)
where M is a measurement operator (e.g. P auli gate).</p>
      <p>As we can see from Equation 5, measuring the target qubit and leaving
untouched the other quantum registers, we obtain the average of di erent
classications based on di erent sub-samples. The separate computation of each base
model is not required; indeed, it is only necessary to generate the quantum state
expressed in Equation 3 and to execute the classi er C once. This implies, when
considering the overall temporal cost of the algorithm, that the single classi er
impacts additively rather than multiplicatively, as it usually happens in
ensemble framework. In fact, in the classical ensemble, it is necessary to train the same
algorithm under B di erent training conditions, and the overall temporal cost
of the algorithm is, at least, the cost of the single classi er times B. In the case
of quantum ensemble, the overall temporal cost of the algorithm depends on
the generation of many sub-samples in superposition, plus one execution of the
quantum classi er that, working via interference, allows propagating the use of
the function f to all sub-samples. Furthermore, given a control register made
up of d qubits, the ensemble size B is equal to 2d. This, in turn, implies that the
ensemble size B scales exponentially with the number of qubits of the control
register, opening up the possibility to achieve exponential speed-up with respect
to the classical ensemble methods.</p>
    </sec>
    <sec id="sec-4">
      <title>Experiments</title>
      <p>We provide small-scale experiments to show how quantum ensemble works. To
the best of our knowledge, there is no quantum classi er which ful ls the
requirements of Eq.(4); this problem will be investigated in future works. However, we
show that given a unitary C that implements a generic function f , whose output
is sensitive to the comparison between two inputs (train and test ), it is possible
to leverage the quantum algorithm described in Section 3 to obtain the average
of multiple outputs of f , by implementing C only once.</p>
      <p>control j0i
x1 j0i
x2 j0i
temp j0i</p>
      <p>x~ j0i
favg j0i</p>
      <p>H
S(x)</p>
      <p>S(x~)</p>
      <p>
        We consider two 2-dimensional training vectors encoded in the amplitudes of
two di erent qubits (training register) and a single qubit for each of the other
registers (control, temp, test, target ). As quantum gate C, we use the swap test [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]
which is a procedure to check how much two quantum states di er. In particular,
given two vectors xi and xj encoded in the amplitudes of two di erent qubits
(jxii ; jxj i), the nal state before measurement of the swap test is:
1 1
2 j0i jxii jxj i + jxj i jxii + 2 j1i jxii jxj i
jxj i jxii :
(6)
Measuring the rst qubit of this state produces outcome j0i with probability
(1 + j hxijxj i j2)=2. This probability is 1 if xi = xj .
      </p>
      <p>The quantum algorithm for the ensemble of swap tests (Figure 1) entangles
the two training vectors with the two quantum states of the control qubit. Then,
the temp qubit is given as input to the swap test, together with the test qubit.
This procedure allows to obtain the average distance between the test vector
and the two training vectors through a single execution of the swap test. To
show that the idea of ensemble works, we generated 20 random datasets, each
made up of three vectors (x1, x2, xtest). We implemented the circuit in Figure 1
and then measured the target qubit. Results are reported in Figure 2. The plot
on the left shows the experiments considering the quantum simulator that
assumes a fault-tolerant quantum computer. The agreement between the quantum
ensemble (orange line) and the classical ensemble (blue line) is almost perfect;
this con rms the possibility to perform quantum ensemble with the advantages
described in Section 3. The plot on the right shows the results using a real
device (ibmq 16 melbourne). In this case, we can see a signi cant deterioration.
This may be due to the depth of the implemented circuit, which seems to be
prohibitive considering the actual quantum devices.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion</title>
      <p>In this work, we proposed a quantum algorithm for ensemble classi cation that
uses bagging strategy. Besides the theoretical algorithm, we provided small-scale
experiments to show how the algorithm works. In particular, we showed that it is
possible to produce a quantum ensemble by executing the classi cation routine
only once. The algorithm provides advantages in terms of temporal
computational complexity, although it is not complete in its technical formulation.</p>
      <p>
        Future works will be dedicated to design a proper quantum classi er C, which
is able to provide di erent outputs based on di erent training sets. In fact, the
ensemble outperforms the single model only if the outputs of the base models
are accurate and diverse [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Also, a generalised quantum routine V to generate
the sampling in superposition has to be designed.
      </p>
      <p>Although some challenges still remain, we believe that this work may be the
rst step to show that QML can overcome the limitations of classical ML in the
context of ensemble classi cation.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Aaronson</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Read the ne print</article-title>
          .
          <source>Nature Physics</source>
          <volume>11</volume>
          (
          <issue>4</issue>
          ),
          <volume>291</volume>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Breiman</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Random forests</article-title>
          .
          <source>Machine learning 45(1)</source>
          ,
          <volume>5</volume>
          {
          <fpage>32</fpage>
          (
          <year>2001</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Buhrman</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cleve</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watrous</surname>
          </string-name>
          , J., de Wolf, R.:
          <article-title>Quantum ngerprinting</article-title>
          .
          <source>Phys. Rev. Lett</source>
          .
          <volume>87</volume>
          ,
          <issue>167902</issue>
          (Sep
          <year>2001</year>
          ). https://doi.org/10.1103/PhysRevLett.87.167902, https://link.aps.org/doi/10.1103/PhysRevLett.87.167902
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Dietterich</surname>
          </string-name>
          , T.G.:
          <article-title>Ensemble methods in machine learning</article-title>
          .
          <source>In: International workshop on multiple classi er systems</source>
          . pp.
          <volume>1</volume>
          {
          <fpage>15</fpage>
          . Springer (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Hansen</surname>
            ,
            <given-names>L.K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Salamon</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Neural network ensembles</article-title>
          .
          <source>IEEE Transactions on Pattern Analysis and Machine Intelligence</source>
          <volume>12</volume>
          (
          <issue>10</issue>
          ),
          <volume>993</volume>
          {1001 (Oct
          <year>1990</year>
          ). https://doi.org/10.1109/34.58871
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Hastie</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tibshirani</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Friedman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Franklin</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>The elements of statistical learning: data mining, inference and prediction</article-title>
          .
          <source>The Mathematical Intelligencer</source>
          <volume>27</volume>
          (
          <issue>2</issue>
          ),
          <volume>83</volume>
          {
          <fpage>85</fpage>
          (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Minka</surname>
            ,
            <given-names>T.P.</given-names>
          </string-name>
          :
          <article-title>Bayesian model averaging is not model combination</article-title>
          . Available electronically at http://www. stat. cmu. edu/minka/papers/bma. html pp.
          <volume>1</volume>
          {
          <issue>2</issue>
          (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Nielsen</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chuang</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Quantum computation and quantum information (</article-title>
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Schuld</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Petruccione</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Quantum ensembles of quantum classi ers</article-title>
          .
          <source>Scienti c reports 8</source>
          (
          <issue>1</issue>
          ),
          <volume>2772</volume>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>