python 相关性分析

 计算相关系数

import numpy

temp=numpy.corrcoef(X,Y)
r=temp[0][1]

reference 

https://jingyan.baidu.com/article/60ccbceba822f464cab1972a.html

tips

1.相关系数对异常值敏感 

ECratio[120,3]=-99,第一个相关系数为0.051

ECratio[120,3]=0,第一个相关系数为0.074

回归系数 t检验

python 线性回归 统计检验 p值_线性回归模型理论&案例

https://blog.csdn.net/weixin_39862871/article/details/109911742?utm_term=python%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92t%E6%A3%80%E9%AA%8C&utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~sobaiduweb~default-0-109911742&spm=3001.4430

使用 sklearn

https://scikit-learn.org/stable/modules/linear_model.html#ordinary-least-squares

中文解释

https://blog.csdn.net/walk_power/article/details/82924363?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

使用statsmodels

基于表格数据

1.

https://blog.csdn.net/weixin_44835596/article/details/89716684

2.

https://www.cnblogs.com/dhcn/p/13474762.html

基于随机生成的数据

https://www.cnblogs.com/youcans/archive/2021/05/06/14734197.html

Python数模笔记-StatsModels 统计回归(2)线性回归

https://www.cnblogs.com/youcans/archive/2021/05/06/14734197.html

import statsmodels.api as sm
xin=SRratio
yin=ECratio[:,1]
# 创建线性回归最小二乘法模型
x = np.array(xin).reshape(-1,1)
y = np.array(yin).reshape(-1,1)
x = np.asarray(x,'int64')
y = np.asarray(y,'int64')
xx= sm.add_constant(x)
#xx=np.hstack((np.ones((65,1)),x))
model = sm.OLS(y,xx)
results = model.fit()
results.summary()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值