F1 Score is the harmonic mean of Precision and Recall
xxxxxxxxxx
from sklearn.metrics import f1_score
# Calculate F1 Score
f1 = f1_score(y_true, y_pred)
print("F1 Score:", f1)
Precision measures the model's ability to not mistake a class
Recall measures the model's ability to recognize a class
xxxxxxxxxx
# 2. Histogram - Age distribution of passengers
ages = titanic_df.age
plt.hist(x=ages, bins=20, edgecolor='black')
plt.title('Age Distribution of Passengers')
plt.ylabel('Frequency')
plt.xlabel('Age')
plt.show()