当前位置:网站首页>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 (8)
- Guess riddles (4)
- ABC#237 C
- Reasons for the insecurity of C language standard function scanf
- U8g2 drawing
- TF coordinate transformation of common components of ros-9 ROS
- TypeScript手把手教程,简单易懂
- Programming implementation of ROS learning 2 publisher node
- Use arm neon operation to improve memory copy speed
- Guess riddles (6)
猜你喜欢
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
猜谜语啦(142)
猜谜语啦(4)
Guess riddles (5)
STM32 lights up the 1.8-inch screen under Arduino IDE
Use and programming method of ros-8 parameters
Redis实现高性能的全文搜索引擎---RediSearch
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
[牛客网刷题 Day4] JZ35 复杂链表的复制
Illustration of eight classic pointer written test questions
随机推荐
猜谜语啦(7)
Yolov4 target detection backbone
kubeadm系列-02-kubelet的配置和启动
Lori remote control commissioning record
RT-Thread内核快速入门,内核实现与应用开发学习随笔记
696. Count binary substring
Business modeling of software model | vision
Bit operation related operations
Agile project management of project management
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
Redis实现高性能的全文搜索引擎---RediSearch
319. 灯泡开关
Shift operation of complement
Use and programming method of ros-8 parameters
My university
Run菜单解析
Typical low code apaas manufacturer cases
How to manage the performance of R & D team?
Digital analog 1: linear programming
Guess riddles (10)