VOOZH about

URL: https://www.analyticsvidhya.com/blog/2021/05/five-number-summary-for-analysis/

⇱ Five Number Summary | How To Calculate 5 Number Summary


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Five Number Summary for Analysis!

Deepanshi Last Updated : 21 Oct, 2024
5 min read
This article was published as a part of the Data Science Blogathon.

Introduction

Statistics is the foundation of Data Science. Before jumping to any Machine Learning model or complex modeling techniques, one should be well versed in the basics which are Statistics.

There are two areas of Statistics which is used in Data Science – Descriptive Statistics and Inferential Statistics.

Today, In this article we will learn about the simplest concept of Descriptive Statistics which is used in understanding our datasets before applying any transformations to the data. The topic of today’s discussion is Five Number Summary.

I will try to explain this concept in the most simplistic way so keep on reading πŸ™‚

Table of Contents


  1. What is Five Number Summary



  2. How to calculate Five Number Summary



  3. How it is used in the interpretation of data



  4. Box plots and How they are constructed


What is Five Number Summary

Descriptive Statistics involves understanding the distribution and nature of the data. Five number summary is a part of descriptive statistics and consists of five values and all these values will help us to describe the data.


  • The minimum value (the lowest value)



  • 25th Percentile or Q1



  • 50th Percentile or Q2 or Median



  • 75th Percentile or Q3



  • Maximum Value (the highest value)


How to calculate Five Number Summary

Let’s understand this with the help of an example . Suppose we have some data such as : 11,23,32,26,16,19,30,14,16,10

Here, in the above set of data points our Five Number Summary are as follows :

First of all , we will arrange the data points in ascending order and then calculate the summary : 10,11,14,16,16,19,23,26,30,32


  • Minimum value: 10



  • 25th Percentile: 14


Calculation of 25th Percentile : (25/100)*(n+1) = (25/100)*(11) = 2.75 i.e 3rd value of the data


  • 50th Percentile : 17.5


Calculation of 50th Percentile : (16+19)/2 = 17.5


  • 75th Percentile : 26


Calculation of 75th Percentile : (75/100)*(n+1) = (75/100)*(11) = 8.25 i.e 8th value of the data


  • Maximum value: 32


How is it used in the interpretation of data?

Now, our major question is that How the Five number Summary values describe our data? Let’s understand this practically using a dataset.

We are going to use a subset of the famous Titanic dataset.

import pandas as pd
data=pd.read_csv('titanic.csv')
data=data[['Age','Fare','Survived']]
print(data.head()) 

Here our data consists of 3 columns, Age, Fare, and Survived. Age and Fare are independent variables and Survived is a dependent variable with two categories, 1 means Survived and 0 means not survived.

Please find the link to the dataset attached.

We will use the describe function in Python to see the Five Number Summary and other details of the data. describe() function gives us the count and mean of the features including the summary values.

data.describe()
Output :
πŸ‘ data description

Understanding Summary values from data’s perspective and describing our data based on the same :


  • From the Fare Column, we can analyze that our 25th Percentile is 7.9 i.e 8 which means 25% of the data is less than 8.



  • 75th Percentile value is 31 meaning 75% of data lies below 31.



  • One major thing to note is that there is a major difference between the 75 percentile value and maximum value, which can be interpreted as the Fare feature is highly skewed and does not follow a Normal Distribution.



  • The presence of outliers can also be detected from such differences.



  • Another thing to note is that Mean>Median(50th Percentile) i.e 32>14 so the distribution is skewed to the right. We can also check the value of skewness using a python function called data.skew().



  • Same interpretations can be made for the Age column. There is not a huge difference between the maximum and 75th percentile values and Median and Mean values are kind of the same so the distribution is not highly skewed.


Checking the distribution of Fare column in Python. We can confirm from the below figure that Fare is skewed towards the right and the presence of outliers can also be detected.

import matplotlib.pyplot as plt
plt.hist(data.Fare,bins=20)
Output :
πŸ‘ histogram

Now, Checking the distribution of the Age column. We can justify our interpretation of the Age column from the below figure.

plt.hist(data.Age,bins=20);
Output :
πŸ‘ histogram 2 five number summary

Another and more efficient way to detect outliers is Boxplot which is constructed from the Five Summary values.

Box plots and how they are constructed?

Boxplots are the graphical representation of the distribution of the data using Five Number summary values. It is one of the most efficient ways to detect outliers in our dataset.

πŸ‘ five number summary boxplot

In statistics, an outlier is a data point that differs significantly from other observations. An outlier may be due to variability in the measurement or it may indicate experimental error; the latter are sometimes excluded from the dataset. An outlier can cause serious problems in statistical analyses.

Plotting the boxplot of the data points taken for the above example (11,23,32,26,16,19,30,14,16,10) where the Five number summary was :

  • Minimum value: 10
  • 25th Percentile: 14
  • 50th Percentile: 17.5
  • 75th Percentile: 26
  • Maximum value: 32

Plotting the boxplot of Fare Column of Titanic Dataset. We can see the number of outliers present in the column Fare in the below graph and it needs to be treated before Model building.

import seaborn as sns
sns.boxplot(data.Fare);
Output :

End Notes :

Another use of 5 Number Summary is the calculation of IQR i.e Inter Quartile Range which helps to deal with outliers. We will study this some other time, but for now, I hope you understood the basic interpretation of data from this simple concept of Five Number Summary.

Feel free to share your thoughts and suggestions here or on LinkedIn

About the Author

I am Deepanshi Dhingra currently working as a Data Science Researcher, and possess knowledge of Analytics, Exploratory Data Analysis, Machine Learning, and Deep Learning.

The media shown in this article are not owned by Analytics Vidhya and is used at the Author’s discretion. 

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
πŸ‘ Av Logo White

Continue your learning for FREE

Forgot your password?
πŸ‘ Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

πŸ‘ Popup Banner
πŸ‘ AI Popup Banner