Search⌘ K

Predict Survival

Explore how to predict passenger survival by applying a variational quantum-classical algorithm in a quantum Bayesian network. Learn data pre-processing, applying quantum gates based on passenger attributes, training the quantum Bayesian network, and interpreting output measurements to improve classification outcomes.

Let’s see how it performs on predicting the survival of the passengers.

We’ll apply our proven procedure of a variational quantum-classical algorithm. We’ll start with pre-processing the data to prepare a quantum state, evaluate the quantum state, and post-process the measurement.

Pre‐processing

The pre-processing is quite simple.

Javascript (babel-node)
def pre_process(passenger):
return (passenger['IsChild'] == 1, passenger['Sex'] == 'female', passenger['Pclass'])

We’ll take the entry of a passenger and return a tuple of whether the value of IsChild is 1, the value of Sex is female, and the ticket-class. We’ll apply these three values in the quantum circuit.

Applying the known data on the quantum circuit

Python 3.5
def apply_known(qc, is_child, is_female, pclass):
if is_child:
qc.x(QPOS_ISCHILD)
if is_female:
qc.x(QPOS_SEX)
qc.x(QPOS_FIRST if pclass == 1 else (QPOS_SECOND if pclass == 2 else QPOS_THIRD))

If the passenger is a child, we apply an XX-gate on the qubit at the position QPOS_ISCHILD in lines 2-3. Since Qiskit initializes the qubits in-state ...