Data itself speaks nothing, but visualization helps us to understand the data, through visualization we can get better insights that can help drive the business in the right direction.
In this blog we will be doing Univariate analysis (Plots for a single variable) using Matplotlib and Seaborn library to talk about different visualizations in Python.
Matplotlib is used for creating Static visualizations.Seaborn is made over top of Matplotlib and has a high level visualization.We will begin by importing Matplotlib, Seaborn, pandas and numpy libraries…
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
It is one of the most and frequently used visualization. It represents the frequency distribution of a continuous variable. We can divide the data into bins as well.
Let us take some age data and analyze its frequency distribution…
Let us plot a histogram to analyze the data…
plt.title(‘Distribution of Age’)
Kernel Density Plot
It is used to see the probability distribution of the variables and often used in data analytics to see whether the data follows a normal distribution or not.
Let us plot this
Distplot combines both histogram and Kernel density plot together to give you a more enhanced version of the visualization.
It is one of the most used graphs for the detection of outliers.
Outliers are the observations that lie far away from majority of observations or you can say extreme values.
Any value that is beyond min and max is a outlier, so one can easily identify the presence of outlier through this
Let us see whether our age variable has outlier or not
In the age variables there seems to be no outlier as none of the point is above or below min and max point.
Let us take another example…
In this we have created a variable and have deliberately entered two extreme values 30 and 32, let us see whether boxplot can identify them or not
As you can clearly see boxplot has identified the presence of two outliers in the data as shown above.
Conclusion: Visualization is the key in data analysis and data exploration. This blog introduces you to different visualization techniques that can be used to know your data.