Predicting Titanic Survivors

Udacity intro to data science course has a project that involves predicting the probability of a passenger being a survivor on the Titanic.  To successfully complete the task you need to have a higher than 80% accuracy rate.

The following is the heuristic that I programmed. I can’t take credit for this as I got my inspiration from Hal Varian’s paper. The heuristic has a 80.47% accuracy rate.

# Assume they aren't a survivor by default
survivor = False
# Prediction model variables
passenger_id = passenger["PassengerId"]
sex = passenger["Sex"]
pclass = passenger["Pclass"]
age = passenger["Age"]
sibsp = passenger["SibSp"]
# Let's find the Survivors
if sex == "female" and pclass <= 2:
     survivor = True
elif sex == "male" and pclass > 1 and age <= 9 and sibsp <= 2:
     survivor = True
# Set the prediction for the passenger
if survivor:
     predictions[passenger_id] = 1
     predictions[passenger_id] = 0