iT邦幫忙

2021 iThome 鐵人賽

DAY 23
0
自我挑戰組

終極大數據地獄系列 第 23

#23 數據中中的特徵相關性(2)

相關距離(Correlation Distance)

  • 相關距離定義:
    https://chart.googleapis.com/chart?cht=tx&chl=D_%7BXY%7D%3D1-%5Crho_%7BXY%7D

python實現相關係數

import numpy as np


def get_coe(a, b):
    return np.corrcoef(a, b)


if __name__ == '__main__':
    a = np.array([1, 3, 564, 675, 6567])
    b = np.array([1, 3, 5566, 675, 6567])
    print(a)
    print(b)
    print(get_coe(a, b))

output

[[1.         0.73430611]  #以a為參照資料
 [0.73430611 1.        ]] #以b為參照資料

相關係數矩陣的含義是:如果把a當作參照資料(自己與自己相關程度為1),那麼與b的相關程度為0.73430611


上一篇
#22 數據中中的特徵相關性(1)
下一篇
#24 數據中中的特徵相關性(3)
系列文
終極大數據地獄24
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言