Python数据分析以及可视化

引入网址:https://www.kaggle.com/benhamner/d/uciml/iris/python-data-visualizations/notebook

 

import matplotlib.pyplot as plt

import seaborn as sns

import pandas as pd

导入数据:

iris=pd.read_csv('E:\\data\\Iris.csv')

iris.head()

 


作直方图:

plt.hist(iris['SepalLengthCm'],bins=15)

plt.xlabel('SepalLengthCm')

plt.ylabel('quantity')

plt.title('distribution of SepalLengthCm')

plt.show()



作散点图:


但是这样的图并没有将其中的不同种类话=花的颜色标明出来。所以我们使用另一种方式,通过Species来分类

 

小提琴图

箱型图:

ax=sns.boxplot(x="Species",y="SepalWidthCm",data=iris)


这里使用jitter=True使得所有点不全落在中间的这条垂直线上

ax=sns.boxplot(x="Species",y="SepalWidthCm",data=iris)

ax=sns.stripplot(x="Species",y="SepalWidthCm",data=iris,jitter=True,edgecolor="gray")



kdeplot:单变量之间的联系,并通过一个核密度评估变量潜在的特征



显示两个变量之间的联系:



通过diag_kind='kde'显示双变量间的核密度并用其估计其特征



boxplot_1:通过Species将变量间的各个特征分离出来



Andrews curves:安德鲁曲线使用样本的属性作为傅里叶变换的系数

 



Radviz:多变量可视化,每一个特征都在一个平面上显示出来,样本通过圈上的点与之像联系起来


parallel_coordinates通过平行坐标进行多变量可视化:对于数据样本的每一个特征,我们通过在坐标轴上设置特征并通过画线的方式来进行设置

posted @ 2017-06-09 21:33  cris_tina  阅读(5485)  评论(0编辑  收藏  举报