当前位置:网站首页>Pearson correlation coefficient
Pearson correlation coefficient
2022-07-05 08:50:00 【Python code doctor】
# 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 Prefix
rockVMines = pd.read_csv('../rockdata.txt',header=None,prefix="V") #prefix 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 Find the correlation coefficient matrix
print(corMat)
plot.pcolor(corMat)
plot.show()
边栏推荐
猜你喜欢

容易混淆的基本概念 成员变量 局部变量 全局变量

Guess riddles (3)

How to manage the performance of R & D team?

Halcon clolor_ pieces. Hedv: classifier_ Color recognition

深度学习模型与湿实验的结合,有望用于代谢通量分析

Programming implementation of ROS learning 5-client node

Business modeling | process of software model

Arduino burning program and Arduino burning bootloader

Pytorch entry record
![[daiy4] copy of JZ35 complex linked list](/img/bc/ce90bb3cb6f52605255f1d6d6894b0.png)
[daiy4] copy of JZ35 complex linked list
随机推荐
Wheel 1:qcustomplot initialization template
使用arm Neon操作,提高内存拷贝速度
C# LINQ源码分析之Count
U8g2 drawing
Count of C # LINQ source code analysis
猜谜语啦(6)
深度学习模型与湿实验的结合,有望用于代谢通量分析
C语言标准函数scanf不安全的原因
How to manage the performance of R & D team?
C [essential skills] use of configurationmanager class (use of file app.config)
GEO数据库中搜索数据
ROS learning 1- create workspaces and function packs
Programming implementation of ROS learning 6 -service node
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
Basic number theory - fast power
多元线性回归(梯度下降法)
Esp8266 interrupt configuration
Configuration and startup of kubedm series-02-kubelet
我从技术到产品经理的几点体会
Confusing basic concepts member variables local variables global variables