Seaborn实现回归分析

import numpy as np
import pandas as pd
from scipy import stats,integrate
import matplotlib.pyplot as plt
import seaborn as sns

# iris = pd.read_csv("iris.csv")
# # 对角线上是单个数据的情况,旁边的图都是关系分布的情况
# sns.pairplot(iris)
# plt.show()

tips = pd.read_csv("tips.csv")
# print(tips.head())

# # 画图方式 regplot() 和 lmplot
# sns.regplot(x = "total_bill",y = "tip",data = tips)
# x y 都是原数据的列名
# plt.show()

# # lmplot 画图方式,支持更高级的功能,但是规范多
# sns.lmplot(x = "total_bill",y = "tip",data = tips)
# plt.show()

# sns.lmplot(x = "size",y = "tip",data = tips)
# plt.show()

# 加上抖动,使回归更准确
sns.regplot(x = "size",y = "tip",data = tips,x_jitter=0.08)
# x_jitter=0.05 在原始数据集中加上小范围浮动
plt.show()

2020-04-24

猜你喜欢

转载自www.cnblogs.com/hany-postq473111315/p/12766396.html