医学统计python之数据相关:欧式距离

使用列表List作为样本点表示的欧氏距离计算方法:

import pandas as pd
import numpy as np
source_path = ‘/Users/apple/Desktop/my_excel.xlsx’
data = pd.DataFrame(pd.read_excel(source_path))
#获取标签列
feature_cols = [‘CT’,‘MR’,‘True’]
x = data[feature_cols[0]]
y = data[feature_cols[1]]
z = data[feature_cols[2]]
#欧式距离
a1 = np.sqrt(np.sum(np.square(x-z)))
a2 = np.sqrt(np.sum(np.square(y-z)))
print(a1,a2)

上一篇:Codeforces #691 div2.E Latin Square


下一篇:Rust 迭代器与闭包与高阶函数