Turning the Problem into a Circuit
Get familiarized with the concept of turning the problem into a circuit.
Our dataset contains roughly 900 of the 1,300 passengers of the Titanic. The columns SibSp
and Parch
indicate the number of passenger’s respective relatives among the other passengers.
For instance, Rev. Ernest Courtenay Carter has one sibling or spouse but no parents or children traveling with him. However, we don’t know who the relative is. We don’t even know whether they’re part of the data or not.
Passenger no 250
print(train[train["PassengerId"].eq(250)])
To find the respective relative, we need to consider three columns of interest. These are the name, the ticket, and the cabin.
In our dataset, we expect two relatives to have the same last name. Let’s look at all the passengers who share their last name with Mr. Carter.
Get potential relatives
current_passenger = train[train["PassengerId"].eq(250)]last_name = current_passenger.Name.to_string(index=False).split(',')[0]print(train[train["Name"].str.contains(last_name)])
We select Mr. Carter by his PassengerId
() in line 1. The Name
...