Open In App

Seaborn Datasets For Data Science

Last Updated : 27 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Seaborn, a Python data visualization library, offers a range of built-in datasets that are perfect for practicing and demonstrating various data science concepts. These datasets are designed to be simple, intuitive, and easy to work with, making them ideal for beginners and experienced data scientists alike.

In this article, we'll explore the different datasets available in Seaborn, their characteristics, advantages, and disadvantages, and how they can be used for various data analysis and visualization tasks.

1. Tips Dataset

The Tips dataset contains information about tips received by waitstaff in a restaurant. It's commonly used for regression and exploratory data analysis (EDA). The dataset includes features such as total bill amount, tip amount, gender of the person paying the bill, whether the person is a smoker, day of the week, time of day, and size of the party.

Advantages: Simple and intuitive, good for demonstrating basic statistical analysis and visualization.
Disadvantages: Small size limits complexity of analyses, limited to restaurant tipping context.

Features and Characteristics

  • total_bill: Total bill amount (numerical)
  • tip: Tip amount (numerical)
  • sex: Gender of the person paying the bill (categorical)
  • smoker: Whether the person is a smoker (categorical)
  • day: Day of the week (categorical)
  • time: Time of day (Lunch/Dinner) (categorical)
  • size: Size of the party (numerical)

How to load Tips Dataset?

import seaborn as sns
tips = sns.load_dataset("tips")
print(tips.head())
total_billtipsexsmokerdaytimesize
16.991.01FemaleNoSunDinner2
10.341.66MaleNoSunDinner3
21.013.50MaleNoSunDinner3
23.683.31MaleNoSunDinner2
24.593.61FemaleNoSunDinner4

2. Iris Dataset

The Iris dataset is one of the most famous datasets used in pattern recognition literature. It contains measurements of iris flowers from three different species. The dataset includes features such as sepal length, sepal width, petal length, petal width, and species of the iris flower.

Advantages: Widely used and well-understood, excellent for classification and clustering demonstrations.
Disadvantages: Small dataset, limited to flower measurements.

Features and Characteristics

  • sepal_length: Sepal length in cm (numerical)
  • sepal_width: Sepal width in cm (numerical)
  • petal_length: Petal length in cm (numerical)
  • petal_width: Petal width in cm (numerical)
  • species: Species of the iris flower (categorical)

How to load Iris Dataset?

iris = sns.load_dataset("iris")
print(iris.head())
sepal_lengthsepal_widthpetal_lengthpetal_widthspecies
5.13.51.40.2setosa
4.93.01.40.2setosa
4.73.21.30.2setosa
4.63.11.50.2setosa
5.03.61.40.2setosa

3. Penguins Dataset

The Penguins dataset provides measurements for three species of penguins. It includes features such as species of the penguin, island where the penguin was observed, bill length, bill depth, flipper length, body mass, and sex of the penguin.

Advantages: Good for classification and clustering, richer and more diverse than the iris dataset.
Disadvantages: Contains missing values, limited to penguin measurements.

Features and Characteristics

  • species: Species of the penguin (categorical)
  • island: Island where the penguin was observed (categorical)
  • bill_length_mm: Bill length in mm (numerical)
  • bill_depth_mm: Bill depth in mm (numerical)
  • flipper_length_mm: Flipper length in mm (numerical)
  • body_mass_g: Body mass in grams (numerical)
  • sex: Sex of the penguin (categorical)

How to load Penguins Dataset?

penguins = sns.load_dataset("penguins")
print(penguins.head())
speciesislandbill_length_mmbill_depth_mmflipper_length_mmbody_mass_gsex
AdelieTorgersen39.118.71813750Male
AdelieTorgersen39.517.41863800Female
AdelieTorgersen40.318.01953250Female
AdelieTorgersennannannannannan
AdelieTorgersen36.719.31933450Female

4. Flights Dataset

The Flights dataset includes information about the number of passengers on flights over a period of years. It includes features such as year of the observation, month of the observation, and number of passengers.

Advantages: Suitable for time series analysis, simple and easy to understand.
Disadvantages: Limited to passenger data, data is somewhat outdated.

Features and Characteristics

  • year: Year of the observation (numerical)
  • month: Month of the observation (categorical)
  • passengers: Number of passengers (numerical)

How to load flights dataset?

flights = sns.load_dataset("flights")
print(flights.head())
yearmonthpassengers
1949Jan112
1949Feb118
1949Mar132
1949Apr129
1949May121

5. Diamonds Dataset

The Diamonds dataset contains information about diamonds, including their characteristics and prices. It includes features such as carat weight, cut, color, clarity, depth, table, price, length, width, and depth in mm.

Advantages: Real-world dataset with diverse features, suitable for regression and clustering tasks.
Disadvantages: Large dataset with many features may require preprocessing, limited to diamond data.

Features and Characteristics

  • carat: Carat weight of the diamond (numerical)
  • cut: Quality of the cut (Fair, Good, Very Good, Premium, Ideal) (categorical)
  • color: Diamond color, from D (best) to J (worst) (categorical)
  • clarity: A measurement of how clear the diamond is (categorical)
  • depth: Total depth percentage (numerical)
  • table: Width of the top of the diamond relative to the widest point (numerical)
  • price: Price in US dollars (numerical)
  • x: Length in mm (numerical)
  • y: Width in mm (numerical)
  • z: Depth in mm (numerical)

How to load diamonds dataset?

diamonds = sns.load_dataset("diamonds")
print(diamonds.head())
caratcutcolorclaritydepthtablepricexyz
0.23IdealESI261.5553263.953.982.43
0.21PremiumESI159.8613263.893.842.31
0.23GoodEVS156.9653274.054.072.31
0.29PremiumIVS262.4583344.204.232.63
0.29Very GoodJSI263.3583354.344.352.75

6. Titanic Dataset

The Titanic dataset contains information about passengers on the Titanic, including whether they survived or not. It includes features such as whether the passenger survived, ticket class, gender of the passenger, age of the passenger, number of siblings/spouses aboard the Titanic, number of parents/children aboard the Titanic, passenger fare, and port of embarkation.

Advantages: Rich dataset with various features, suitable for survival prediction and demographic analysis.
Disadvantages: Contains missing values, historical dataset may not represent modern demographics.

Features and Characteristics

  • survived: Whether the passenger survived (0 = No, 1 = Yes) (categorical)
  • pclass: Ticket class (1st, 2nd, 3rd) (categorical)
  • sex: Gender of the passenger (categorical)
  • age: Age of the passenger (numerical)
  • sibsp: Number of siblings/spouses aboard the Titanic (numerical)
  • parch: Number of parents/children aboard the Titanic (numerical)
  • fare: Passenger fare (numerical)
  • embarked: Port of embarkation (C = Cherbourg, Q = Queenstown, S = Southampton) (categorical)

How to load Titanic Dataset?

titanic = sns.load_dataset("titanic")
print(titanic.head())
survivedpclasssexagesibspparchfareembarked
03male22.0107.25S
11female38.01071.3C
13female26.0007.92S
11female35.01053.1S
03male35.0008.05S

7. Exercise Dataset

The Exercise dataset contains information about individuals' pulse measurements after different types of exercise. It includes features such as participant ID, type of diet, pulse rate, time after exercise, and type of exercise.

Advantages: Good for time series analysis, simple and easy to understand.
Disadvantages: Limited to pulse measurements, small dataset.

Features and Characteristics

  • id: Participant ID (numerical)
  • diet: Type of diet (Low Fat or High Fat) (categorical)
  • pulse: Pulse rate (numerical)
  • time: Time after exercise (numerical)
  • kind: Type of exercise (categorical)

How to load Exercise Dataset?

exercise = sns.load_dataset("exercise")
print(exercise.head())
iddietpulsetimekind
1low851rest
1low8515rest
1low8830rest
1low9045rest
1low9260rest

8. MPG Dataset

The MPG dataset contains information about miles per gallon for different car models and their attributes. It includes features such as miles per gallon, number of cylinders in the engine, engine displacement, engine horsepower, vehicle weight, acceleration, model year, origin of the car, and car model name.

Advantages: Real-world dataset with diverse features, suitable for regression analysis and predicting fuel efficiency.
Disadvantages: Some missing values in the horsepower column, large dataset with many features.

Features and Characteristics

  • mpg: Miles per gallon (numerical)
  • cylinders: Number of cylinders in the engine (numerical)
  • displacement: Engine displacement in cubic inches (numerical)
  • horsepower: Engine horsepower (numerical)
  • weight: Vehicle weight in pounds (numerical)
  • acceleration: Acceleration in seconds from 0 to 60 mph (numerical)
  • model_year: Model year (categorical)
  • origin: Origin of the car (1 = American, 2 = European, 3 = Japanese) (categorical)
  • name: Car model name (string)

How to load MPG Dataset?

mpg = sns.load_dataset("mpg")
print(mpg.head())
mpgcylindersdisplacementhorsepowerweightaccelerationmodel_yearoriginname
18.08307.0130.0350412.0701chevrolet chevelle ...
15.08350.0165.0369311.5701buick skylark 320
18.08318.0150.0343611.0701plymouth satellite ...
16.08304.0150.0343312.0701amc rebel sst
17.08302.0140.0344910.5701ford torino

9. Planets Dataset

The Planets dataset includes information about exoplanets, such as their orbital periods and masses. It includes features such as method of detecting the exoplanet, number of planets in the system, orbital period, mass of the planet, and distance from Earth.

Advantages: Unique dataset in the field of astronomy, suitable for exploring exoplanet characteristics and trends.
Disadvantages: Limited to exoplanetary data, small dataset compared to other astronomical datasets.

Features and Characteristics

  • method: Method of detecting the exoplanet (categorical)
  • number: Number of planets in the system (numerical)
  • orbital_period: Orbital period in Earth days (numerical)
  • mass: Mass of the planet in Jupiter masses (numerical)
  • distance: Distance from Earth in light-years (numerical)

How to load Planets Dataset?

planets = sns.load_dataset("planets")
print(planets.head())
methodnumberorbital_periodmassdistance
Radial Velocity1269.37.177.4
Radial Velocity1874.82.256.95
Radial Velocity1763.02.619.84
Radial Velocity1326.019.4110.62
Radial Velocity1516.010.5119.47

Conclusion

Seaborn's built-in datasets provide valuable resources for practicing various data science techniques, from basic exploratory data analysis to advanced machine learning tasks. Each dataset has its own characteristics, advantages, and disadvantages, making them suitable for different applications.

By exploring and analyzing these datasets, you can gain valuable insights into data visualization, statistical analysis, and machine learning algorithms. Experimenting with different datasets and techniques is key to improving your data science skills and understanding real-world data.


Similar Reads