Technical Report: Titanic Passenger List
Tags: datascience, dataanalysis, titanic, python
Published: 2024-07-01 07:48:10

**Introduction**
The Titanic dataset, available on Kaggle, contains detailed information about the passengers aboard the ill-fated RMS Titanic. This dataset is a popular choice for data analysis and machine learning practice due to its rich variety of numerical and categorical variables. The purpose of this review is to conduct an initial exploration of the dataset, identifying key insights and patterns at first glance.

**Observations**
Upon examining the Titanic dataset, several initial observations can be made:

**Survival Rate: **The dataset includes a Survived column, where 0 indicates the passenger did not survive, and 1 indicates survival. A quick count of this column shows that a minority of passengers survived the disaster. Specifically, only about 38% of the passengers survived, highlighting the tragedy's severity.

`# Basic survival rate calculation
survival_rate = df['Survived'].mean()`

**Passenger Class Distribution:** The dataset contains a Pclass column indicating the class of travel (1st, 2nd, or 3rd class). A review shows that the majority of passengers were in the 3rd class, followed by 1st and then 2nd class. This distribution suggests a diverse socio-economic background among the passengers.


```
# Distribution of passenger classes
class_distribution = df['Pclass'].value_counts()

```
**Age Distribution: ** The Age column reveals the age distribution of the passengers. The dataset includes a range of ages from infants to elderly passengers. A histogram of the ages shows a concentration of passengers in their 20s and 30s, with fewer children and older adults. There are also some missing values in the Age column, which could impact further analysis.

```
# Basic age distribution and missing values
age_distribution = df['Age'].describe()
missing_age_values = df['Age'].isnull().sum()
```
**Visualization**
To support these observations, a simple visualization of the age distribution can be helpful. Below is a histogram depicting the age distribution of the passengers.

```
import matplotlib.pyplot as plt
import seaborn as sns

# Loading the Titanic dataset
df = sns.load_dataset('titanic')

# Histogram of passenger ages
plt.hist(df['Age'].dropna(), bins=30, edgecolor='black')
plt.title('Age Distribution of Titanic Passengers')
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.show()
```
**The image output will be **

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k82omhqcvxj2h90vp2x.png)

**Conclusion**
In summary, the Titanic dataset reveals several initial insights:

- The survival rate among passengers was low, with only about 38% surviving.

- The majority of passengers traveled in the 3rd class, indicating a varied socio-economic passenger base.

- The age distribution shows a concentration of passengers in their 20s and 30s, with some missing age data that could be addressed in further analysis.

These observations provide a foundation for more in-depth exploration and analysis. Future steps could include examining the impact of different variables on survival rates, filling missing age values using predictive modeling, and exploring relationships between other variables such as fare, gender, and passenger class.

For more information about data analysis and internship opportunities, visit the HNG Internship websites at [HNG Internship](https://hng.tech/internship) and [HNG Hire](https://hng.tech/hire).