This project uses a Decision Tree Classifier to predict passenger survival on the Titanic based on selected features such as age, fare, and class. It also includes a simple prediction for a hypothetical passenger and a scatter plot to visualize actual vs. predicted outcomes.
titanic.csvβ Dataset with passenger information (must be placed in the same directory)titanic_survival_decision_tree.pyβ Python script for training, testing, and predictingREADME.mdβ Project documentation
The Titanic dataset contains demographic and travel information of passengers. The target variable is:
Survived: 1 if the passenger survived, 0 otherwise
| Feature | Description |
|---|---|
| Pclass | Passenger class (1 = 1st, 2 = 2nd, 3 = 3rd) |
| Sex | Gender (encoded: male = 0, female = 1) |
| Age | Age in years (missing values imputed) |
| SibSp | Number of siblings/spouses aboard |
| Parch | Number of parents/children aboard |
| Fare | Ticket fare (missing values imputed) |
- Model: Decision Tree Classifier
- Library:
scikit-learn - Evaluation Metric: Accuracy
The model is trained using 80% of the data and tested on the remaining 20%.
A scatter plot compares actual survival outcomes with predicted outcomes.
The script includes an example prediction for a new passenger with the following features:
- Class: 2nd
- Gender: Female
- Age: 30
- Siblings/Spouses aboard: 0
- Parents/Children aboard: 0
- Fare: 10
Prediction output:
Prediction for new passenger: Survived