# Improving 2-5 Qubit Quantum Phase Estimation Circuits Using Machine Learning
## 1 Introduction
### Data Understanding  
The phases of data understanding, data preparation, modeling and evaluation from the cross-industry standard process for data mining (CRISP-DM) were followed in this analysis [8]. The first phase seeks to understand the datasets analyzed in this work. The datasets were generated using a simulated QPE circuit created using IBM's qiskit, for 2-, 3-, 4- and 5-qubit circuits in a process described in Sections 2.1 and 2.2. In a circuit with \(n\) qubits in the first register, we measure \(n\) qubits once the QPE algorithm described in the introduction is implemented. Each qubit is measured as a 0 or 1. Since there are \(n\) of these qubits, we can measure \(2^{n}\) possible outputs. When this sequence of \(n\) qubits is considered as a binary number, it can be converted into a decimal number ranging from 0 if all 0's are measured, to \(2^{n}-1\) if all 1's are measured. A single \"shot\" of the circuit, corresponding to one sampling from the probability distribution described in the Introduction, is just one of these values in the range 0 to \(2^{n}-1\). The same circuit is run repeatedly to sample many times from the probability distribution. An example for a 2-qubit circuit is presented: if we measure it 400 times and 00 is measured 100 times, 01 is measured 200 times, 10 is measured 50 times, and 11 is measured 50 times, then the feature 00 takes on the value \(100/400=0.25\). In a similar manner, feature 01 takes on the value \(200/400=0.5\), and features 10 and 11 take on the value \(50/400=0.125\). Therefore, the vector of features representing one data point would be [0.25, 0.5, 0.125, 0.125], and we would hope to derive an estimation of the phase from this vector of four features. The process is analogous in systems of higher qubits, and the number of features grows like \(2^{n}\). In this experiment, we have generated a dataset with these feature vectors for many different circuits with some associated phase and recorded the noise parameter (described in Section 2.2) and the phase in order to train the model. Each row of the dataset contains the transmitted phase, the added noise level and the features that contain the quantum information. For a 2-qubit system there are four features, and the \(3/4/5\) qubit systems have \(8/16/32\) features, respectively. For the 2-qubit dataset, histograms with kernel density estimate overlay are presented in Figure 3 for the transmitted phase (left) and induced noise level (right). Uniform distributions of phase and noise were expected as the transmitted phase was randomly generated, and data were generated uniformly for 21 different noise levels. If these values were unequally distributed,  
Figure 2: Example of undesired model performance that varies with the level of simulated noise (**left**) and desired level model performance with the level of simulated noise (**right**). The model metric in the \(y\)-axis is the mean squared error (MSE), and these examples use the XGBoost algorithm with different levels of the maximum depth parameter. it would be difficult to verify that model performance was consistent across their range. The datasets for the 2-qubit and 5-qubit systems contained 210,000 rows, the 3-qubit dataset contained 52,500 rows, and the 4-qubit dataset contained 105,000 rows. It is expected that the distributions of each channel in an n-qubit system will be similar, and Figure 4 confirms this, showing histograms of each channel for the 2- and 3-qubit systems. Verifying this expectation in Figure 4 increased confidence in the integrity of the large datasets. The non-normal distributions are the expected result of the QPE probability (Equation (6)) and the injected noise levels. In each sub-panel of Figure 3, the non-normal distributions are explained as follows:  
* Values near 0 should occur most often, while values close to 1 only occur when the phase exactly lines up with a value of \(k/2^{n}\), where \(k\) is an integer between 0 and \(2^{n}-1\).