1 Star 0 Fork 0

Cube/Relevance_Project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Pearson算法实现.py 723 Bytes
一键复制 编辑 原始数据 按行查看 历史
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
X = [52,19,7,33,2]
Y = [162,61,22,100,6]
# X=[
# 12.5, 15.3, 23.2, 26.4, 33.5,
# 34.4, 39.4, 45.2, 55.4, 60.9]
# Y=[
# 21.2, 23.9, 32.9, 34.1, 42.5,
# 43.2, 49.0, 52.8, 59.4, 63.5]
# X = [2,19,7,33,2]
# Y = [62,61,22,100,6]
#公式计算
#均值
XMean = np.mean(X)
YMean = np.mean(Y)
#标准差
XSD = np.std(X)
YSD = np.std(Y)
#z分数
ZX = (X-XMean)/XSD
ZY = (Y-YMean)/YSD
#相关系数
r = np.sum(ZX*ZY)/(len(X))
t=np.corrcoef(X,Y)
print('X:\n',X)
print('Y:\n',Y)
print('XMean:\n', XMean)
print('YMean:\n', YMean)
print('XSD:\n', XSD)
print('YSD:\n', YSD)
print('ZX:\n', ZX)
print('ZY:\n', ZY)
print('r:\n',r)
print('t:\n',t)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/worldlab/relevance_-project.git
[email protected]:worldlab/relevance_-project.git
worldlab
relevance_-project
Relevance_Project
master

搜索帮助