I'm currently trying to refer to a value from an excel spreadsheet that is full of passenger data for the titanic disaster. Here is the part I'm stuck on.
Examining the survival statistics, a large majority of males did not survive the ship sinking. However, a majority of females did survive the ship sinking. Let's build on our previous prediction: If a passenger was female, then we will predict that they survived. Otherwise, we will predict the passenger did not survive. Fill in the missing code below so that the function will make this prediction.
Hint: You can access the values of each feature for a passenger like a dictionary. For example, passenger['Sex'] is the sex of the passenger.
def predictions_1(data):
""" Model with one feature:
- Predict a passenger survived if they are female. """
predictions = []
for _, passenger in data.iterrows():
# Remove the 'pass' statement below
# and write your prediction conditions here
if passenger['Sex'] == 'female':
survived == 1
else survived == 0
# Return our predictions
return pd.Series(predictions)
# Make the predictions
predictions = predictions_1(data)
File "<ipython-input-75-6b2fca23446d>", line 12
else survived == 0
^
SyntaxError: invalid syntax
I input the if else statement and I'm positive there are many errors in my attempt, I'd appreciate some clarity to how to fix this, the data from the excel sheet is the survived and sex data. Here is the github link to the project I'm working on. https://github.com/udacity/machine-learning/tree/master/projects/titanic_survival_exploration