> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Isometry encoding

haiqu.isometry\_encoding()

This notebook demonstrates how to use `haiqu.isometry_encoding()` to encode a vector of real features into a quantum state.

For 1000 classical features known techniques in the literature would require as many qubits for the encoding, which falls beyond the capabilities of current hardware. The same vector can be encoded into a more complex Hilbert space with a proposed technique lowering the amount of needed qubits to 100 and less and controllable by the user.

haiqu.isometry\_encoding()

What does it do? Isometry encoding embeds classical real feature vector via parametrization of the Hilbert space of controllable complexity. How do I use it? Pass a real vector to create a data loading job, then retrieve results with job.result(). What are the options? Optional density parameter controls the complexity of the quantum state and amount of features which can be encoded. Additional hyperparameters for circuit synthesis include num\_layers, truncation\_cutoff and fine\_tuning\_iterations. Which option do you recommend? Start with the default settings for basic use cases. Observe how many qubits are used in the process and tune the denisty if necessary.

Having a bug or an issue?

Submit feedback

Initialize the benchmark

Import the necessary libraries, initialize the Haiqu SDK, create a desired quantum state.

```python theme={null}
import qiskit
import numpy as np
import pandas as pd
from haiqu.sdk import haiqu
import matplotlib.pyplot as plt
from qiskit.circuit.library import StatePreparation

haiqu.login()
haiqu.init("Isometry Encoding Tutorial")

rng = np.random.default_rng(seed=42)

feature_vector_size = 1000
features = rng.normal(size=feature_vector_size)  # a real vector with 1000 values

densities = [1, 2, 3, 4]
```

Run benchmark scenarios

Prepare an encoding into a quantum state with different densities.

```python theme={null}
qubits = []

for density in densities:
    job = haiqu.isometry_encoding(features, density=density)
    qc, _ = job.result()
    qubits.append(qc.num_qubits)
```

Haiqu's isometry encoding allows to encode larger feature vectors for quantum machine learning tasks:

```python theme={null}
for nq, density in zip(qubits, densities):
    print(f"Encoding of {feature_vector_size} classical features with density {density} requires {nq} qubits.")
```

While denstities 1-2 require more qubits than generally available in today's quantum hardware, it is possible to successfully encode 1000 features with a proposed method with density 3 and 4.

💡 Good to Know: Isometry Encoding with density set to 1 naturally produces the angular encoding, which requires as many qubits as there are features and is the most common in quantum machine learning. Proposed technique allows to naturally extend this encoding by parametrizing a more complex Hilbert space.

Get in Touch

Documentation portal [docs.haiqu.ai](https://docs.haiqu.ai)

Contact Support [feedback.haiqu.ai](https://feedback.haiqu.ai)

Follow Us on LinkedIn latest news on [LinkedIn](https://www.linkedin.com/company/haiquai/)

Visit Our Website Learn more about Haiqu Inc. on [haiqu.ai](https://haiqu.ai)

Business Inquiries Contact us at [info@haiqu.ai](mailto:info@haiqu.ai)
