Machine Learning Model Comparison: Supervised and Unsupervised Learning on the Titanic Dataset

Pratik Sutar Avatar

Introduction

Machine Learning offers several approaches for solving prediction and pattern-discovery problems. Selecting the right algorithm is important because different algorithms can behave differently on the same dataset.

In this project, I performed a structured comparison of three Machine Learning approaches using the Titanic dataset. The project combines concepts from Machine Learning fundamentals, supervised learning, unsupervised learning, and model evaluation.

The main objective was to train multiple models, evaluate their performance using appropriate metrics, apply an unsupervised learning technique, and determine which approach would be the most suitable for the problem.

Dataset

For this project, I used the Titanic dataset, which contains information about passengers who travelled on the Titanic.

Important features include PassengerId, Pclass, Sex, Age, SibSp, Parch, Fare, Cabin, Embarked, and Survived.

The target variable for supervised learning was Survived:

  • 0 = Did not survive
  • 1 = Survived

Before applying Machine Learning algorithms, the dataset was explored and cleaned using Python and Pandas.

Data Preprocessing

Data preprocessing is an important step in any Machine Learning project. First, I loaded the dataset and examined its structure, data types, statistical information, and missing values.

Missing values were handled appropriately. For example, missing values in the Age column were replaced using the median age. Columns with a large amount of missing information, such as Cabin, were considered for removal.

Categorical variables such as Sex and Embarked were converted into numerical representations so that Machine Learning algorithms could process them.

After preprocessing, the dataset was divided into input features and the target variable. A train/test split was then performed to evaluate the models on unseen data.

Supervised Learning Models

For supervised learning, I selected two different classification algorithms:

Logistic Regression

Logistic Regression is a popular algorithm for binary classification. In this project, it was used to predict whether a passenger survived the Titanic disaster.

One advantage of Logistic Regression is that it is relatively simple and interpretable. It provides a useful baseline for classification problems.

Decision Tree

The second model was a Decision Tree Classifier.

A Decision Tree works by creating a series of decision rules based on the input features. Unlike Logistic Regression, it can capture non-linear relationships between features and the target.

Using two genuinely different algorithms allowed me to make a meaningful comparison rather than simply changing parameters of the same model.

Model Evaluation

Training a Machine Learning model is not enough. It is important to evaluate how well the model performs on data that it has not seen during training.

For this project, I used a train/test split and evaluated the models using multiple classification metrics:

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Confusion Matrix

Accuracy measures the overall percentage of correct predictions.

Precision measures how many of the passengers predicted as survivors were actually survivors.

Recall measures how many of the actual survivors were correctly identified.

The F1-score combines precision and recall and provides a balanced measure of classification performance.

I also generated confusion matrices to understand the types of correct and incorrect predictions made by each model.

Unsupervised Learning with K-Means

In addition to supervised learning, I applied an unsupervised learning technique using K-Means Clustering.

Unlike supervised learning, K-Means does not use the target variable while creating clusters. Instead, it attempts to identify natural groups based on similarities between passengers.

After creating the clusters, I compared the resulting groups with the original Survived variable.

This helped answer an interesting question: Do the naturally discovered passenger groups have different survival patterns?

The clustering results provided another perspective on the dataset without directly using the survival label during the clustering process.

Model Comparison

The supervised models were compared using multiple evaluation metrics.

ModelAccuracyPrecisionRecallF1-Score
Logistic RegressionActual ResultActual ResultActual ResultActual Result
Decision TreeActual ResultActual ResultActual ResultActual Result

The final values should be taken directly from the actual experiment rather than being assumed beforehand.

This comparison makes it easier to understand which algorithm provides better overall performance on the test dataset.

Which Model Would I Recommend?

The final model should not be selected based only on accuracy.

For this project, I would consider the model that provides the best overall balance between accuracy, precision, recall, and F1-score.

If Logistic Regression provides stable performance with good interpretability, it can be a strong choice. If the Decision Tree performs better across the evaluation metrics, it may be preferred because of its ability to capture non-linear relationships.

Therefore, the final recommendation should be based on the actual test results and the requirements of the problem.

Key Learnings

This project helped me strengthen my understanding of the complete Machine Learning workflow.

I learned how to:

  • Prepare and preprocess a real-world dataset
  • Perform train/test splitting
  • Build different supervised learning models
  • Apply Logistic Regression
  • Apply Decision Tree Classification
  • Evaluate classification models
  • Use accuracy, precision, recall, and F1-score
  • Interpret confusion matrices
  • Apply K-Means clustering
  • Compare clusters with a supervised target
  • Compare different Machine Learning approaches
  • Select a model based on evaluation results

Conclusion

This project provided practical experience in comparing supervised and unsupervised Machine Learning techniques on the Titanic dataset.

Logistic Regression and Decision Tree were used for supervised classification, while K-Means was used to discover natural groups within the passenger data.

The project demonstrated that Machine Learning model selection should be based on proper evaluation rather than simply choosing the most complex algorithm. Using multiple metrics and understanding the business or problem context are important when selecting a final model.

Overall, this project helped me connect concepts from ML fundamentals, supervised learning, unsupervised learning, and model evaluation into one practical end-to-end Machine Learning project.

Technologies Used

Python | Pandas | NumPy | Scikit-learn | Matplotlib

Pratik Sutar Avatar

Leave a Reply

You May Love