Skip to content

🛳️ Titanic Survival Analysis

📋 Overview

This project explores the Titanic dataset to analyze survival rates based on gender. Using Python and data visualization libraries, we uncover insights into the survival patterns of passengers aboard the Titanic.

🛠️ Steps

1. ⚙️ Set Up Your Environment

  • Install Anaconda or ensure your Python setup is ready.
  • Install required libraries:
    pip install pandas matplotlib seaborn
    

2. 📂 Load the Titanic Dataset

  • Open Jupyter Notebook and create a new Python notebook named Titanic Survival Analysis.
  • Load the dataset and display the first few rows:
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    # Load Titanic dataset from seaborn
    df = sns.load_dataset('titanic')
    
    # Display first few rows to understand data
    df.head()
    

3. 📊 Analyze Survival Rates by Gender

  • Group the data by gender and calculate the average survival rate:
    # Group data by gender and calculate average survival rate
    survival_by_gender = df.groupby('sex')['survived'].mean().reset_index()
    
    # Display the result
    print(survival_by_gender)
    

4. 📈 Visualize the Data

  • Create a bar chart to visualize survival rates by gender:
    # Create a bar plot to show survival rate by gender
    sns.barplot(x='sex', y='survived', data=survival_by_gender)
    
    # Add labels and title
    plt.title('Survival Rate by Gender')
    plt.ylabel('Survival Rate')
    plt.xlabel('Gender')
    
    # Show the plot
    plt.show()
    

5. 📝 Observations and Conclusion

  • Example observation:
    • "The survival rate for females was significantly higher than for males, with around 74% of women surviving compared to only 19% of men."

6. 💾 Save Your Work

  • Save your notebook as titanic_survival_analysis.ipynb.

7. 🌐 Upload Your Project to GitHub

  • Create a GitHub repository named titanic-survival-analysis.
  • Upload your Jupyter notebook to the repository.

8. 💼 Share on LinkedIn

  • Example LinkedIn post:
    🔍 Mini Data Insight from My Learning Journey in Data Science
    While exploring the Titanic dataset 🛳️, I discovered:
    🎯 Female survival rate: ~74% 🎯 Male survival rate: ~19%
    This shows how historical data can reveal social patterns!
    Tools used: Python, Pandas, Seaborn
    Project on GitHub: https://github.com/MoizKhawar/titanic-survival-analysis
    #LearningDataScience #Python #DataAnalytics #TitanicDataset #MiniProject
    

🛠️ Tools Used

  • 🐍 Python
  • 📊 Pandas
  • 📈 Seaborn
  • 📉 Matplotlib

🔗 GitHub Repository

View the project on GitHub