当前位置:网站首页>皮尔森相关系数
皮尔森相关系数
2022-07-05 08:42:00 【python-码博士】
# encoding:utf-8
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plot
import math
#target_url = ("https://archive.ics.uci.edu/ml/machine-learning-databases/undocumented/connectionist-bench/sonar/sonar.all-data")
#rockVMines = pd.read_csv(target_url ,header=None,prefix="V") #prefix前缀
rockVMines = pd.read_csv('../rockdata.txt',header=None,prefix="V") #prefix前缀
row2 = rockVMines.iloc[1,0:60]
row3 = rockVMines.iloc[2,0:60]
n = len(row2)
mean2 = row2.mean()
mean3 = row3.mean()
t2=0 ; t3=0;t1=0
for i in range(n):
t2 += (row2[i] - mean2) * (row2[i] - mean2) / n
t3 += (row3[i] - mean3) * (row3[i] - mean3) / n
r23=0
for i in range(n):
r23 += (row2[i] - mean2)*(row3[i] - mean3)/(n* math.sqrt(t2 * t3))
print(r23)
corMat = DataFrame(rockVMines.corr()) #corr 求相关系数矩阵
print(corMat)
plot.pcolor(corMat)
plot.show()
边栏推荐
- [three tier architecture]
- 【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
- [noi simulation] juice tree (tree DP)
- Hello everyone, welcome to my CSDN blog!
- 实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
- STM32 lights up the 1.8-inch screen under Arduino IDE
- Business modeling of software model | vision
- Old Wang's esp8266 and old Wu's ws2818 light strip
- Arduino burning program and Arduino burning bootloader
- PIP installation
猜你喜欢

剑指 Offer 06. 从尾到头打印链表
![[牛客网刷题 Day4] JZ55 二叉树的深度](/img/f7/ca8ad43b8d9bf13df949b2f00f6d6c.png)
[牛客网刷题 Day4] JZ55 二叉树的深度

Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase

319. Bulb switch

猜谜语啦(142)

Guess riddles (11)

STM32 summary (HAL Library) - DHT11 temperature sensor (intelligent safety assisted driving system)
![[three tier architecture]](/img/73/c4c75a453f03830e83cabb0762eb9b.png)
[three tier architecture]

猜谜语啦(2)

L298N module use
随机推荐
[nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)
【日常训练--腾讯精选50】557. 反转字符串中的单词 III
Apaas platform of TOP10 abroad
MATLAB小技巧(28)模糊综合评价
实例008:九九乘法表
Esphone retrofits old fans
Business modeling | process of software model
第十八章 使用工作队列管理器(一)
[牛客网刷题 Day4] JZ35 复杂链表的复制
Infix expression evaluation
STM32---IIC
剑指 Offer 09. 用两个栈实现队列
How can fresh students write resumes to attract HR and interviewers
Reasons for the insecurity of C language standard function scanf
[three tier architecture]
Guess riddles (4)
One question per day - replace spaces
实例010:给人看的时间
Bluebridge cup internet of things basic graphic tutorial - GPIO output control LD5 on and off
[牛客网刷题 Day4] JZ32 从上往下打印二叉树