This project is a machine learning exploration focused on predicting the age of passengers from the Titanic dataset. It serves as a practical exercise in data cleaning, feature engineering, and model evaluation.
This repository documents the end-to-end process, from the data preprocessing to the evaluation of model performance.
The project utilizes the tested.csv file from the Titanic dataset, which contains various details for each passenger, including their class, fare, and family size.
-
Clone the repository:
git clone [https://github.com/AS200585/Titanic-ML-Project.git](https://github.com/AS200585/Titanic-ML-Project.git) cd Titanic-ML-Project -
Install the required libraries:
pip install pandas numpy scikit-learn matplotlib
-
Run the script:
python titanic-prediction.py
An initial set of models was built using the available features. This approach produced extremely high R-squared scores, suggesting near-perfect prediction capabilities.
| Model | Test Rยฒ Score |
|---|---|
| Linear Regression | 0.830 |
| Lasso Regression | 0.844 |
| Gradient Boosting | 0.999 |
Upon review, it was discovered that the near-perfect scores of the GradientBoostingRegressor were a result of data leakage.
The following steps are planned to improve the model's predictive power:
- Smarter Imputation: Replace the simple
fillna(0)strategy for missingAgevalues with a more robust method, such as filling with the median age. - Feature Engineering: Convert categorical columns like
SexandEmbarkedinto numerical format using one-hot encoding. - Feature Selection: Remove non-informative features like
PassengerIdthat only add noise to the model. - Hyperparameter Tuning: Once the features are improved, fine-tune model parameters to optimize performance and reduce overfitting.