当前位置:网站首页>皮尔森相关系数
皮尔森相关系数
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()
边栏推荐
- Redis实现高性能的全文搜索引擎---RediSearch
- 整形的分类:short in long longlong
- MATLAB skills (28) Fuzzy Comprehensive Evaluation
- Sword finger offer 09 Implementing queues with two stacks
- Bluebridge cup internet of things competition basic graphic tutorial - clock selection
- [matlab] matlab reads and writes Excel
- Chapter 18 using work queue manager (1)
- Latex improve
- Some pitfalls of win10 network sharing
- Halcon snap, get the area and position of coins
猜你喜欢

Halcon shape_ trans

Bluebridge cup internet of things competition basic graphic tutorial - clock selection

猜谜语啦(8)

Typical low code apaas manufacturer cases

Example 007: copy data from one list to another list.

Low code platform | apaas platform construction analysis

【三层架构及JDBC总结】

Example 006: Fibonacci series

Guess riddles (10)
![[three tier architecture and JDBC summary]](/img/e0/13d48f2e59b445b9e28e38d45f492d.png)
[three tier architecture and JDBC summary]
随机推荐
287. 寻找重复数-快慢指针
图解八道经典指针笔试题
Business modeling of software model | stakeholders
Arduino burning program and Arduino burning bootloader
猜谜语啦(4)
猜谜语啦(142)
Guess riddles (142)
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
My university
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
[牛客网刷题 Day4] JZ35 复杂链表的复制
Redis实现高性能的全文搜索引擎---RediSearch
GEO数据库中搜索数据
UE pixel stream, come to a "diet pill"!
Old Wang's esp8266 and old Wu's ws2818 light strip
Infected Tree(树形dp)
每日一题——替换空格
An enterprise information integration system
如何写Cover Letter?
Business modeling | process of software model