Effective Data Visualization Techniques in Data Science Using Python
Effective Data Visualization Techniques in Data Science Using Python
Data Visualization
they could optimize the data for business strategy plans for ongoing activities.
Operational and Performance analysis:
Increase the productivity of the manufacturing unit: With the help of visualization techniques
the clarity of KPIs depicting the trends of the productivity of the manufacturing unit, and guiding
were to improve the productivity of the plant.
Data visualization techniques most important part of Data Science, There won’t be any doubt about it.
And even in the Data Analytics space as well the Data visualization doing a major role. We will discuss
this in detail with help of Python packages and how it helps during the Data Science process flow. This
is a very interesting topic for every Data Scientist and Data Analyst.
I. Line Chart
Line charts are used to represent the relation between two data X and Y on the respective axis. Let’s
see a few samples
Sample #1
import numpy as np
#simple array
x = np.array([1, 2, 3, 4])
#genearting y values
y = x*2
plt.plot(x, y)
plt.show()
Sample #2
x = np.array([1, 2, 3, 4])
y = np.array([2, 4, 6, 8])
plt.plot(x, y)
plt.xlabel("Time in Hrs")
plt.ylabel("Distance in Km")
plt.title("Time Vs Distance")
plt.show()
Line Chart always a linear relationship between X and Y axis, we observe that in the above picture.
II.Histogram
The histogram is the graphical representation of a set of numerical data distribution across. It is a kind
of bar plot with X-axis and Y-axis represents the bin ranges and frequency respectively. How to read or
represent this chart.
Let say the example, set of students marks in the ranges and frequency as below. Here we could
understand the range and frequency cut off exactly.
import numpy as np
fig,ax = plt.subplots(1,1)
a = np.array([25,42,48,55,60,62,67,70,30,38,44,50,54,58,75,78,85,88,89,28,35,90,95])
ax.set_title("Student's Score")
ax.set_xticks([0,20,40,60,80,100])
ax.set_xlabel('Marks Scored')
ax.set_ylabel('No. of Students')
plt.show()
Characteristics Of Histogram
Displot – This is similar to the histogram in the graphical, but with additional features. And
bringing Kernel Density Estimation (KDE).
Jointplot – A combination of scattering and histogram.
df = sns.load_dataset('tips')
III.Pie Chart
This is a very familiar chart and representation statistical plot in the form of circular from series of data.
This is commonly used in business presentations to represent Order, Sales, Profit, Loss, etc., It
consists of slices of data part in the collection of the same set and character-wise differentiation. Each
of the slices of pie is called a wedge with values of different sizes.
This chart is widely used to represent the composition collection. Perfect for the categorical data type.
import numpy as np
# Creating plot
# show plot
plt.show()
import numpy as np
myexplode = [0.2, 0, 0, 0]
plt.show()
This is very similar to a line chart with fencing surrounded by a boundary line of different colours.
Simple representation of the evolution of a numeric variable.
import matplotlib.pyplot as plt
days = [1, 2, 3, 4, 5]
plt.xlabel('Days')
plt.ylabel('No of Hours')
plt.show()
V. Scatter plots
Scatter plots are used to plot data points across both axes (Horizontal and Vertical) and represent how
each axis correlated with each other. Mostly in Data Science/Machine Learning implementation and
before the EDA process, generally we should analyse how dependent and independent aligned. It could
positive or Negative or sometimes be scattered across the graph.
import matplotlib.pyplot as plt
x = [5,7,8,7,2,17,2,9,4,11,12,9]
y = [99,86,87,88,67,86,87,78,77,85,86,56]
plt.scatter(x, y)
plt.show()
x = [5,7,8,10,14,18,22,26]
y = [6,8,9,12,16,20,24,28]
plt.scatter(x, y)
plt.show()
The objective of Hexbins is used to group the two sets of numeric values. Hexbins helps to improve the
visualization of the scatter plots. Because for a larger dataset, a scatter plot makes a confused
smattering of points. We can improve this with Hexbins. It provides two modes of representations 1.List
of Coordinates 2.Geospatial Object.
import numpy as np
x = np.random.normal(size=(1, 1000))
y = np.random.normal(size=(1, 1000))
plt.hexbin(x, y, gridsize=15)
plt.show()
VII. Heatmap
A heatmap is one of my favorite visualization techniques among the other charts. basically, a set of
variable correlations is represented by various shades of the same color. Usually, the darker shades of
the chart represent the higher correlations values than the lighter shade. this map would help Data
Scientists to figure out how to target variable is correlated with other dependent variables in the given
data set. Less correlated variables can be removed for further analysis, we could say this helps us
during the feature selection process. Later grouping them under X, Y as our target and followed by test
and train split.
import seaborn as sn
import numpy as np
import pandas as pd
df=pd.DataFrame(np.random.random((7,7)),columns=['a','b','c','d','e','f','g'])
sn.heatmap(df)
sn.heatmap(df,annot=True,annot_kws={'size':7})
VIII. Boxplot
A Boxplot is a type of chart often used in the Data Science life cycle, especially during Explanatory Data
Analysis (EDA). Which represents the distribution of data in the form of quartiles or percentiles. Q1
represents the first quartile (25th percentile), Q2 is the second quartile (50th percentile/median), Q3
represents the third quartile (Q3) and Q4 represents the fourth quartile or the largest value.
Using this plot we could identify the outliers very quickly and easily. This is a very effective plot all
among the plots. So after the removal of outliers, the data set needs to undergo some sort of statistical
test and fine-tune for further analysis.
np.random.seed(10)
one=np.random.normal(100,10,200)
to_plot=[one,two,three,four]
fig=plt.figure(1,figsize=(9,6))
ax=fig.add_subplot()
bp=ax.boxplot(to_plot)
fig.savefig('boxplot.png',bbox_inches='tight')
IX. Pairplot
A pairplot is another important plot in the Data Science life cycle during the EDA process, to analyse
how features are related to each other, in the form of grid-based miniature graphical representation
along the X and Y axis, either positive correlated or negatively correlated. So obviously we could
eliminate the negatively correlated, by considering positively corrected pairs and move for further
analysis. This is very similar to Heat Map, but here we could see the relationship with our naked eyes.
That is special over here. Hope you could fee this. Again this is best for doing the feature selection
process.
import pandas as pd
import seaborn as sb
df = sb.load_dataset('iris')
sb.set_style("ticks")
plt.show()
Line Chart is always linear relation between X and Y axis, we observe that above picture
X. Bar Chart
A bar chart or bar graph is generally a very familiar chart to presents categorical data with rectangular
bars. It can be plotted either way horizontally or vertically. this chart would represent the impact of the
individual’s category on the given dataset. First of first look. In the below chart “America” is much more
impact than “Europe” and “Asia”. This would derive some observation on the dataset and focus on the
problem statement.
fig, ax = plt.subplots(figsize = (5, 5))
labels[0] = 'America'
labels[1] = 'Europe'
labels[2] = 'Asia'
ax.set_xticklabels(labels)
plt.show()
Analysis of variants in Data Science process, it could be Univariate (or) Bi-variate (or) Multivariate.
You can very well refer to the above models with the Charts/Visualization that we have discussed from
You can very well refer to the above models with the Charts/Visualization that we have discussed from
the beginning of the article. Just go through it again. Certainly, you could understand the importance of
these Data visualization techniques.
Thanks for reading this article and I believe it is useful to you. and you could realise this when you go
for Data Science solution implementation before model selection. Even after all model evaluation and
predictions result from comparisons. As below reference charts.