---
title: ZZFeatureMap (v2.3)
description: API reference for qiskit.circuit.library.ZZFeatureMap in qiskit v2.3
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/2.3/qiskit.circuit.library.ZZFeatureMap
---

# ZZFeatureMap

*class* `qiskit.circuit.library.ZZFeatureMap(feature_dimension, reps=2, entanglement='full', data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZZFeatureMap')`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.3/qiskit/circuit/library/data_preparation/_zz_feature_map.py#L21-L152)

Bases: [`PauliFeatureMap`](/docs/api/qiskit/2.3/qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.data_preparation.pauli_feature_map.PauliFeatureMap")

Second-order Pauli-Z evolution circuit.

For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:

```text
┌───┐┌────────────────┐
┤ H ├┤ P(2.0*φ(x[0])) ├──■───────────────────────────■───────────────────────────────────
├───┤├────────────────┤┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ P(2.0*φ(x[1])) ├┤ X ├┤ P(2.0*φ(x[0],x[1])) ├┤ X ├──■───────────────────────────■──
├───┤├────────────────┤└───┘└─────────────────────┘└───┘┌─┴─┐┌─────────────────────┐┌─┴─┐
┤ H ├┤ P(2.0*φ(x[2])) ├─────────────────────────────────┤ X ├┤ P(2.0*φ(x[1],x[2])) ├┤ X ├
└───┘└────────────────┘                                 └───┘└─────────────────────┘└───┘
```

Here, $\varphi$ is a classical non-linear function, which defaults to $\varphi(x) = x$ if $|S| = 1$ and $\varphi(x,y) = (\pi - x)(\pi - y)$ if $|S| > 1$, and $S$ is the set of qubit indices describing the connections in the feature map. See the docstring of `pauli_feature_map()` for more detail.

Examples:

```python
from qiskit.circuit.library import ZZFeatureMap
prep = ZZFeatureMap(2, reps=1)
print(prep.decompose())
```

```text
     ┌───┐┌─────────────┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├──■──────────────────────────────────────■──
     ├───┤├─────────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
     └───┘└─────────────┘└───┘└────────────────────────────────┘└───┘
```

```python
from qiskit.circuit.library import EfficientSU2
classifier = ZZFeatureMap(3).compose(EfficientSU2(3))
classifier.num_parameters
```

```text
27
```

```python
classifier.parameters  # 'x' for the data preparation, 'θ' for the SU2 parameters
```

```text
ParameterView([
    ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
    ParameterVectorElement(x[2]), ParameterVectorElement(θ[0]),
    ParameterVectorElement(θ[1]), ParameterVectorElement(θ[2]),
    ParameterVectorElement(θ[3]), ParameterVectorElement(θ[4]),
    ParameterVectorElement(θ[5]), ParameterVectorElement(θ[6]),
    ParameterVectorElement(θ[7]), ParameterVectorElement(θ[8]),
    ParameterVectorElement(θ[9]), ParameterVectorElement(θ[10]),
    ParameterVectorElement(θ[11]), ParameterVectorElement(θ[12]),
    ParameterVectorElement(θ[13]), ParameterVectorElement(θ[14]),
    ParameterVectorElement(θ[15]), ParameterVectorElement(θ[16]),
    ParameterVectorElement(θ[17]), ParameterVectorElement(θ[18]),
    ParameterVectorElement(θ[19]), ParameterVectorElement(θ[20]),
    ParameterVectorElement(θ[21]), ParameterVectorElement(θ[22]),
    ParameterVectorElement(θ[23])
])
```

```python
classifier.count_ops()
```

```text
OrderedDict([('ZZFeatureMap', 1), ('EfficientSU2', 1)])
```

> **Deprecated since version 2.1**
>
> The class `qiskit.circuit.library.data_preparation._zz_feature_map.ZZFeatureMap` is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Use the zz\_feature\_map function as a replacement. Note that this will no longer return a BlueprintCircuit, but just a plain QuantumCircuit.

**Parameters**

- **feature\_dimension** ([*int*](https://docs.python.org/3/library/functions.html#int)) – Number of features.
- **reps** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The number of repeated circuits, has a min. value of 1.
- **entanglement** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)  *|*[*Dict*](https://docs.python.org/3/library/typing.html#typing.Dict)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*,* [*List*](https://docs.python.org/3/library/typing.html#typing.List)*\[*[*Tuple*](https://docs.python.org/3/library/typing.html#typing.Tuple)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*]]] |* [*Callable*](https://docs.python.org/3/library/typing.html#typing.Callable)*\[\[*[*int*](https://docs.python.org/3/library/functions.html#int)*],* [*str*](https://docs.python.org/3/library/stdtypes.html#str)  *|*[*Dict*](https://docs.python.org/3/library/typing.html#typing.Dict)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*,* [*List*](https://docs.python.org/3/library/typing.html#typing.List)*\[*[*Tuple*](https://docs.python.org/3/library/typing.html#typing.Tuple)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*]]]]*) – Specifies the entanglement structure. Refer to [`PauliFeatureMap`](/docs/api/qiskit/2.3/qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.PauliFeatureMap") for detail.
- **data\_map\_func** ([*Callable*](https://docs.python.org/3/library/typing.html#typing.Callable)*\[\[*[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)*],* [*float*](https://docs.python.org/3/library/functions.html#float)*] | None*) – A mapping function for the data `x`.
- **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The prefix used if default parameters are generated.
- **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True`, barriers are inserted in between the evolution instructions and hadamard layers.
- **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) –

**Raises**

[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the feature dimension is smaller than 2.

## Attributes

### name

Type: `str`

A human-readable name for the circuit.

**Example**

```python
from qiskit import QuantumCircuit

qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
```

```text
my_circuit
```
