栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python数据处理从零开始----第四章(可视化)(9)线性相关曲线

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python数据处理从零开始----第四章(可视化)(9)线性相关曲线

===============================================
通过R语言我们可以绘制两个变量的相关图,我所使用的是皮尔森相关,主要的参数是:①r相关系数②P值。一般对P值的评判标准是P< 0.05

简单的相关系数的分类
0.8-1.0 极强相关
0.6-0.8 强相关
0.4-0.6 中等程度相关
0.2-0.4 弱相关
0.0-0.2 极弱相关或无相关
r描述的是两个变量间线性相关强弱的程度。r的取值在-1与+1之间,若r>0,表明两个变量是正相关,即一个变量的值越大,另一个变量的值也会越大;若r<0,表明两个变量是负相关,即一个变量的值越大另一个变量的值反而会越小。r 的绝对值越大表明相关性越强,要注意的是这里并不存在因果关系。

基础拟合曲线绘制
# -*- coding: utf-8 -*-"""
Created on Mon Nov 19 00:57:53 2018

@author: czh
"""# In[*]#导入各种需要的包#import numpy as npimport matplotlib.pyplot as pltfrom scipy import optimizeimport seaborn as sns
sns.set()# In[*]import seaborn as sns
sns.set(style="darkgrid")

tips = sns.load_dataset("tips")
g = sns.jointplot("total_bill", "tip", data=tips, kind="reg",
                  xlim=(0, 60), ylim=(0, 12), color="m", height=7)


这是通过python语言绘制的线性相关曲线拟合图,感觉比R语言在代码上更简洁,且图片能展示的信息更多。

多分组拟合曲线绘制
# -*- coding: utf-8 -*-"""
Created on Mon Nov 19 00:57:53 2018

@author: czh
"""# In[*]#导入各种需要的包#import numpy as npimport matplotlib.pyplot as pltfrom scipy import optimizeimport seaborn as sns
sns.set()# In[*]# Load the iris datasetiris = sns.load_dataset("iris")# Plot sepal with as a function of sepal_length across daysg = sns.lmplot(x="sepal_length", y="sepal_width",hue='species',
               truncate=True, height=5, data=iris)# Use more informative axis labels than are provided by defaultg.set_axis_labels("Sepal length (mm)", "Sepal width (mm)")



作者:夜神moon
链接:https://www.jianshu.com/p/c53fe1ad15be


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/222329.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号