Baseline

Learn how we can implement and evaluate a classifier.

Now, we have our input data and the resulting labels, and we’ve separated it into a training and testing set. The only thing left is our algorithm.

Our algorithm should predict whether a passenger survived the Titanic shipwreck. This is a classification task since there are distinct outcome values. Specifically, it is a binary classification task because there are precisely two possible predictions, survived or died.

Before developing a quantum machine learning algorithm, let’s implement the simplest algorithm we can imagine: a classifier guess.

A random classifier

Press + to interact
import random
random.seed(a=None, version=2)
def classify(passenger):
return random.randint(0, 1)

We import the random number generator in line 1 ...