Passenger Survival Rates: Insights from the Titanic Data

Analyze Titanic passenger survival rates by passenger class using Seaborn count plots.

Uncover how passenger class influenced survival rates on the Titanic using data visualization. Understand why class emerges as a significant factor in predictive modeling.

Key Insights

  • A majority of Titanic passengers were third-class travelers; despite their numbers, significantly fewer third-class passengers survived compared to first- and second-class passengers.
  • First-class passengers experienced a survival advantage, being more likely to survive than perish, while third-class passengers overwhelmingly perished.
  • Analyzing passenger class through visualizations like Seaborn's count plots suggests passenger class is a valuable feature for predictive modeling of survival on the Titanic.

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

Let's take a look at what we're missing in this graph. We're gonna graph much the same thing, but it's going to be about passenger class instead of just whether passengers survived or perished. Okay, what's the breakdown of our total population by passenger class? Okay.

We're gonna add an axis this time, and we're gonna do that so we can label it; that's why we're saving it as a variable. And we'll say, do a count plot where X is now the Pclass—passenger class—value, and our data is still Titanic data. We can see here, hey, most people were third class, a smaller subsection were second class, and there were slightly more in first class.

Okay, well, that's helpful and all, but what if we want to make a bar chart from two columns at once? In this case, what we're gonna say is, okay, what if we want to plot survival by passenger class? Well, Seaborn has a great way to handle that. What we're gonna do is make our axis; we're going to specify a count plot with X set to survived. We're graphing survived on the X axis, but we're splitting it into different hues by passenger class.

Let's see that. Looks like I need to fix that, make that a little bigger. There we go.

All right, so we have this passenger class breakdown: these bars are passenger class one, these are passenger class two, and these are passenger class three. That's what they mean by hue.

Data Analytics Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Now we can look at survived and perished by passenger class. We can see that third-class passengers accounted for most who perished, while second- and first-class passengers were about the same. First class was proportionately much better, but still, you know, around the same compared to third-class passengers, who perished a lot.

In terms of survival, even though third-class passengers were the largest group, fewer survived than first-class passengers. Second-class passengers did well, too. So yeah, we can also compare these numbers.

If you were first class, you were more likely to survive than perish. In second class, you were a little more likely to have perished than survived. Third-class passengers overwhelmingly perished.

So this seems like it could be an important feature to include. This is the kind of thing that I'm going to talk about in a study where it's like, okay, we should definitely include this. It seems like it might've been predictive and simple.

This will help our model make sense of the data and come up with a formula. Let's take a look at a similar thing—survival by gender—in the next bit.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Machine Learning

Master Machine Learning with Hands-on Training. Use Python to Make, Modify, and Test Your Own Machine Learning Models.

Yelp Facebook LinkedIn YouTube Twitter Instagram