# How does the ZZ Feature Map influence the measurement?

I've been look at this Notebook from qiskit and trying to understand whats happening, but can't quite figure it out.

From my understanding, rotations around the Z Axis do not influence the probabilities of measuring $$|0\rangle$$ and $$|1\rangle$$. So, with my Knowledge, I would assume that the ZZFeatureMap has no direct influence.

After that, the RealAmplitudesis applied which corresponds more to my knowledge. We use weights inside of RY gates to play with the importance of single features and their contribution to the probability of measuring 0/1.

Even after looking at the Bloch sphere after the ZZFeatureMap, I can't see anything special. For example, for this circuit, the Bloch spheres before measurement look like this.

I would assume that given the circuit, my measurements should be a perfect 1/4 split across all 4 possible states, yet that is not the case.

Maybe I'm missing key information/relation between the global phase and measurements. I'm quite intrigued by it, as my circuits that incorporate RY/CRY gates for features and weights barely manage to hit 60% accuracy, where with the same training and problem the ZZFeatureMap + RealAmplitudes achieves a perfect 100% accuracy

• In general, the output of a two-qubit circuit is not expressible as two separate Bloch spheres - this would only be the case if the final state is separable, but it will almost certainly not be given the CNOTs in your circuit that create entanglement. If you extract the final statevector before measurement, you should find amplitudes that agree with the probabilities in the histogram you show. Nov 29, 2021 at 14:19

Rotations about the $$Z$$ axis can certainly affect the probabilities of measuring $$0$$ and $$1$$ when combined with other gates that are not diagonal in the computational basis.

The key here is the presence of the Hadamard gates at the beginning and middle of the circuit. Quantum interference is one way to understand what's going on: After the first layer of Hadamards and a single $$Z$$ rotation are applied the state of the system is

\begin{align}\tag{1} (R_z(\theta) \otimes I)(H \otimes H)|00\rangle &= \frac{1}{2}(R_z(\theta) \otimes I)(|00\rangle + |01\rangle + |10\rangle + |11\rangle)\\ \tag{2} &= \frac{1}{2}(e^{i\theta}|00\rangle + e^{i\theta}|01\rangle + e^{-i\theta}|10\rangle + e^{-i\theta}|11\rangle) \end{align}

Looking at this state, you can imagine that another gate that is not diagonal in the computational basis will combine amplitudes from the different basis states in nontrivial ways. For example applying another $$H$$ gate would give amplitudes looking like $$\frac{1}{2}(e^{i\theta} + e^{-i\theta}) \propto \frac{1}{2} \cos\theta$$. These amplitudes no longer have norm $$1/2$$ and so you won't measure a distribution that is uniform in the computational basis.

Another easier way of seeing this is to just imagine inserting pairs of $$HH = I$$ gates between the $$Z$$ rotations in the circuit you provided. Then you can apply identities like $$H R_z (\theta) H = R_x(\theta)$$ to see how the circuit is actually acting nontrivially on the computational basis states.

my circuits that incorporate RY/CRY gates for features and weights barely manage to hit 60% accuracy, where with the same training and problem the ZZFeatureMap + RealAmplitudes achieves a perfect 100% accuracy

In the original paper, the basic idea was to use the ZZFeatureMap to generate the data classified by the classifier. This explains why the ZZFeatureMap is performing with 100% accuracy: the classification problem was designed so that that specific quantum circuit plus SVM classifier would be expressive enough to learn the exact underlying distribution of data. A classifier based on $$R_y$$ rotations is probably just not expressive enough for this niche problem.