seaborn使用教程

最近为了做数据挖掘的比赛,在不断学习python的这些库,同时学习机器学习的一些算法比如决策树的ID3,C4.5,CART三个算法,SVM,随机森林,梯度提升决策树算法…鉴于我对这些算法的理解还不够深入,因此还是先放我学习python库的代码。之后要实现一下底层,先实现一个ID3试试。
下面给出seaborn的示例代码:

import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy import stats,integrate
%matplotlib inline
#在notebook中显示数据点
import seaborn as sns

plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
np.random.seed(sum(map(ord,"aesthetics")))

seaborn使用教程

def sinplot(flip=1):
    x=np.linspace(0,14,100)
    for i in range(1,7):
        plt.plot(x,np.sin(x+i*.5)*(7-i)*flip)
     
sinplot()

seaborn使用教程

sns.set()
sinplot()

seaborn使用教程

x=np.random.normal(size=100)
sns.distplot(x)
#用distplot()函数快速观察单变量分布,默认使用柱状图。

seaborn使用教程

sns.distplot(x,kde=False,rug=True) 
#kde:曲线,rug:每个观察点上的垂直小标签
``
![在这里插入图片描述](https://img-blog.****img.cn/2019040716353025.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5OTM2Mzg5,size_16,color_FFFFFF,t_70)

df=pd.read_csv('train.csv',index_col=0)
df.head()#看表头,这里的图就不放了
sns.lmplot(x='Pclass',y='Age',data=df)#x为pclass,y为age
sns.lmplot(x='Age',y='Survived',data=df,fit_reg=False,hue='Parch')
sns.boxplot(data=df) #Boxplot

seaborn使用教程
seaborn使用教程
seaborn使用教程