Data Visualization plays a very important role in Data mining. Various data scientist spent their time exploring data through visualization. To accelerate this process we need to have a well-documentation of all the plots.
d ATA可视化起着数据挖掘非常重要的作用。 各种各样的数据科学家花时间通过可视化来探索数据。 为了加快这一过程,我们需要对所有地块都有完整的文档记录。
Even plenty of resources can’t be transformed into valuable goods without planning and architecture. Therefore I hope this article would provide you a good architecture of all plots and their documentation.
没有规划和架构,就连大量资源也无法转化为有价值的商品。 因此,我希望本文能为您提供所有图表及其文档的良好架构。
Introduction
介绍
Know your Data
了解您的数据
Distribution Plotsa. Dist-Plotb. Joint Plotc. Pair Plotd. Rug Plot
分布图。 Dist-Plotb。 联合绘图 对图。 地毯图
Categorical Plotsa. Bar Plotb. Count Plotc. Box Plotd. Violin Plot
分类Plotsa。 酒吧Plotb。 计数Plotc。 箱图。 小提琴图
Advanced Plotsa. Strip Plotb. Swarm Plot
进阶Plotsa。 带状花鼓。 群图
Matrix Plotsa. Heat Mapb. Cluster Map
Matrix Plotsa。 热图 集群图
Gridsa. Facet Grid
Gridsa。 刻面网格
Regression Plots
回归图
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics.
Seaborn是基于matplotlib的Python数据可视化库。 它提供了一个高级界面,用于绘制引人入胜且内容丰富的统计图形。
For the installation of Seaborn, you may run any of the following in your command line.
对于Seaborn的安装,您可以在命令行中运行以下任一命令。
pip install seabornconda install seabornTo import seaborn you can run the following command.
要导入seaborn,您可以运行以下命令。
import seaborn as snsThe data set used in these plots is famous titanic data set (Fig. 1). Hereafter the data set is represented by the variable ‘df’.
这些图中使用的数据集是著名的泰坦尼克号数据集 (图1)。 此后,数据集由变量“ df ”表示。
Fig. 1: Titanic Data set 图1:泰坦尼克号数据集These plots help us to visualize the distribution of data. We can use these plots to understand the mean, median, range, variance, deviation, etc of the data.
这些图帮助我们可视化数据的分布 。 我们可以使用这些图来了解数据的平均值,中位数,范围,方差,偏差等。
These plots help us understand the categorical variables. We can use them for both univariate and bivariate analysis.
这些图帮助我们理解分类变量。 我们可以将它们用于单变量和双变量分析。
It is a 5 point summary plot. It gives the information about the maximum, minimum, mean, first quartile, and third quartile of a continuous variable. Also, it equips us with knowledge of outliers.
这是一个5点汇总图 。 它提供有关连续变量的最大值,最小值,平均值,第一四分位数和第三四分位数的信息。 同样,它为我们提供了离群值的知识。
We can plot this for a single continuous variable or can analyze different categorical variables based on a continuous variable. 我们可以为单个连续变量绘制此图,也可以基于连续变量分析不同的类别变量。 import seaborn as sns#For plot 1sns.countplot(df['Pclass'])#For plot 2sns.boxplot(y = df['Age'], x = df['Sex']) Fig.8: a) Box plot of ‘Age’, b) Box plot of different categories in ‘sex’ for ‘Age’ 图8:a)“年龄”的箱形图,b)“性别”中“年龄”的不同类别的箱形图As the name suggests, they are advanced because they ought to fuse the distribution and categorical encodings.
顾名思义,它们是高级的,因为它们应该融合分发和分类编码。
These are the special types of plots that use two-dimensional matrix data for visualization. It is difficult to analyze and generate patterns from matrix data because of its large dimensions. So, this makes the process easier by providing color coding to matrix data.
这些是使用二维矩阵数据进行可视化的特殊类型的图。 由于矩阵数据的维数较大,因此难以分析和生成模式。 因此,通过为矩阵数据提供颜色编码,这使过程变得更容易。
It seems very difficult to read every value even though there are only 49 values. The intricacy intensifies as we traverse towards thousands of features.
即使只有49个值,读取每个值似乎也很困难。 当我们遍历数以千计的功能部件时,复杂性加剧了。
So, let us try to implement some color coding and see how easy the interpretation becomes.
因此,让我们尝试实现一些颜色编码,看看解释变得多么容易。
sns.heatmap(df.corr(), annot = True, cmap = 'viridis') Fig. 13: Heat Map of the correlation matrix of the titanic data set. 图13:钛酸数据集相关矩阵的热图。 The same matrix is now articulating more information. 现在,同一矩阵可以表达更多信息。 Another very obvious example is to use heatmaps to understand the missing value patterns. In Fig. 14, the yellow dash represents a missing value, hence it makes our tasks more effortless to identify the missing values. 另一个非常明显的示例是使用热图来了解缺失值模式。 在图14中,黄色破折号代表缺失值,因此使我们的任务更加轻松地识别缺失值。 sns.heatmap(df.isnull(),yticklabels=False,cbar=False,cmap='viridis') Fig. 14: Heat Map for missing values in titanic data. 图14:钛酸数据中缺失值的热图。Cluster maps use Hierarchical clustering to form different clusters.
集群图使用层次集群来形成不同的集群。
Grid plots provide us more control over visualizations and plots various assorted graphs with a single line of code.
网格图为我们提供了对可视化的更多控制,并通过一行代码即可绘制出各种图表。
sns.FacetGrid( col = ‘col’, row = ‘row’, data = data) provides an empty grid of all unique categories in the col and row. Later, we can use different plots and common variables for peculiar variations.
sns.FacetGrid ( col =' col ', row =' row ', data = data)提供了col和row中所有唯一类别的空网格。 以后,我们可以使用不同的图和通用变量来进行特殊的变化。
This is a more advanced statistical plot that provides a scatter plot along with a linear fitting on the data.
这是更高级的统计图,它提供了散点图以及对数据的线性拟合。
sns.lmplot(x = 'Age', y = 'PassengerId', data = df, hue = 'Sex) Disclaimer: There is so the significance of regressing age and passenger id. It is just the purpose of understanding visualization. 免责声明 :降低年龄和乘客身份非常重要。 这只是了解可视化的目的。Fig. 17 displays the linear regression fitting between Passenger ID and Age for both males and females.
图17显示了男性和女性的乘客ID和年龄之间的线性回归拟合。
In this article, we have seen 14 different visualization techniques using seaborn.
在本文中,我们已经看到了14种使用seaborn的不同可视化技术。
I believe data visualization enhances our understanding and potential for interpreting data. It gives us more satisfying skills to represent data, impute missing values, identify outliers, detect anomalies, and a lot more.
我相信数据可视化会增强我们的理解力和解释数据的潜力。 它为我们提供了更令人满意的技能来表示数据,估算缺失值,识别异常值,检测异常等等。
Data Analysts are like cops that need to interrogate data and extract information via them. It is extremely necessary to have optimistic tools to do the job. Therefore, I hope this article would serve you as a tool for interrogating your data.
数据分析师就像警察一样,需要审问数据并通过它们提取信息。 拥有乐观的工具来完成这项工作是非常必要的。 因此,我希望本文能为您提供一个查询数据的工具。
For the Guide for Exploratory data analysis, visit-
有关探索性数据分析指南,请访问-
翻译自: https://towardsdatascience.com/14-data-visualization-plots-of-seaborn-14a7bdd16cd7
相关资源:微信小程序源码-合集6.rar