Ensemble classification with Forest and Qiskit devices : Quantum Circuit

Dear all,

Can anyone please explain to me, why the circuit use certain quantum gates (RX, ROT, and CZ)?

Like why should i use those gates and not the other gates?

Hi @quirkyMouse, welcome to the forum!

Using an RX gate is an easy way to encode your features (input data), specially if such data is in the 0-2pi range. These features, denoted with ‘x’, are very different to our training parameters ‘theta’.

After the RX gates, which embed your input data into the circuit, you will need an ansatz. This ansatz is your circuit architecture, or a set of gates which - if used with the right parameters - should model your data well. Your ansatz should be complex enough to be able to represent the complexities in your underlying data, but it shouldn’t be so complex that it results in excessive running time or overfitting.

Choosing a series of generalized rotations (3 parameters per gate) and CZ gates (no parameters per gate) is a simple way to add complexity. For very complex models you could even add additional layers with a similar architecture, or try different ansatze.

Okay, so the data is in the 0-2 pi range, is it when we execute this line of code?
x = 2 * np.pi * (x - x_min) / (x_max - x_min) - np.pi
And can you @CatalinaAlbornoz or anyone please explain to me where is this formula come from also what is this formula used for?

I’m really new to this quantum computing thing so i’m gonna ask a lot of question in the future so please be patient with me

Hi @quirkyMouse, it’s great that you’re asking questions!

That line of code is effectively putting all of your data into the range [-pi , pi], which is also perfectly ok. It’s basically equivalent.

This formula allows you to normalize your data and then shift it to the desired range. I would recommend that you study the Xanadu Quantum Codebook, specifically the introduction module, to keep learning the basics.