Skip to main contentIBM Quantum Documentation
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

qiskit.circuit.library.pauli_feature_map

qiskit.circuit.library.pauli_feature_map(feature_dimension, reps=2, entanglement='full', alpha=2.0, paulis=None, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='PauliFeatureMap')

GitHub

The Pauli expansion circuit.

The Pauli expansion circuit is a data encoding circuit that transforms input data xRn\vec{x} \in \mathbb{R}^n, where nn is the feature_dimension, as

UΦ(x)=exp(iSIϕS(x)iSPi).U_{\Phi(\vec{x})}=\exp\left(i\sum_{S \in \mathcal{I}} \phi_S(\vec{x})\prod_{i\in S} P_i\right).

Here, SS is a set of qubit indices that describes the connections in the feature map, I\mathcal{I} is a set containing all these index sets, and Pi{I,X,Y,Z}P_i \in \{I, X, Y, Z\}. Per default the data-mapping ϕS\phi_S is

ϕS(x)={xi if S={i}jS(πxj) if S>1.\phi_S(\vec{x}) = \begin{cases} x_i \text{ if } S = \{i\} \\ \prod_{j \in S} (\pi - x_j) \text{ if } |S| > 1 \end{cases}.

The possible connections can be set using the entanglement and paulis arguments. For example, for single-qubit ZZ rotations and two-qubit YYYY interactions between all qubit pairs, we can set:

circuit = pauli_feature_map(..., paulis=["Z", "YY"], entanglement="full")

which will produce blocks of the form

┌───┐┌─────────────┐┌──────────┐                                            ┌───────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
├───┤├─────────────┤├──────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───────────┤
┤ H ├┤ P(2.0*x[1]) ├┤ RX(pi/2) ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ RX(-pi/2) ├
└───┘└─────────────┘└──────────┘└───┘└────────────────────────────────┘└───┘└───────────┘

The circuit contains reps repetitions of this transformation.

Please refer to z_feature_map() for the case of single-qubit Pauli-ZZ rotations and to zz_feature_map() for the single- and two-qubit Pauli-ZZ rotations.

Examples

>>> prep = pauli_feature_map(2, reps=1, paulis=["ZZ"])
>>> print(prep)
     ┌───┐
q_0: ┤ H ├──■──────────────────────────────────────■──
     ├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
     └───┘└───┘└────────────────────────────────┘└───┘
>>> prep = pauli_feature_map(2, reps=1, paulis=["Z", "XX"])
>>> print(prep)
     ┌───┐┌─────────────┐┌───┐                                            ┌───┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├┤ H ├──■──────────────────────────────────────■──┤ H ├
     ├───┤├─────────────┤├───┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐├───┤
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ H ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├┤ H ├
     └───┘└─────────────┘└───┘└───┘└────────────────────────────────┘└───┘└───┘
>>> prep = pauli_feature_map(2, reps=1, paulis=["ZY"])
>>> print(prep)
     ┌───┐┌──────────┐                                            ┌───────────┐
q_0: ┤ H ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2)
     ├───┤└──────────┘┌─┴─┐┌────────────────────────────────┐┌─┴─┐└───────────┘
q_1: ┤ H ├────────────┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├─────────────
     └───┘            └───┘└────────────────────────────────┘└───┘
>>> from qiskit.circuit.library import efficient_su2
>>> prep = pauli_feature_map(3, reps=3, paulis=["Z", "YY", "ZXZ"])
>>> wavefunction = efficient_su2(3)
>>> classifier = prep.compose(wavefunction)
>>> classifier.num_parameters
27
>>> classifier.count_ops()
OrderedDict([('cx', 39), ('rx', 36), ('u1', 21), ('h', 15), ('ry', 12), ('rz', 12)])

References:

[1] Havlicek et al. Supervised learning with quantum enhanced feature spaces, Nature 567, 209-212 (2019).

Parameters

Return type

QuantumCircuit

Was this page helpful?
Report a bug or request content on GitHub.