iT邦幫忙

2023 iThome 鐵人賽

DAY 14
0
AI & Data

初探 Network Science系列 第 14

Day-14-Paper Reading -- Graph Embedding - 續

  • 分享至 

  • xImage
  •  

Problem Formalization

Notation

  • https://chart.googleapis.com/chart?cht=tx&chl=%24g%20%3D%20(V%2C%20E)%24 ---> graph
  • https://chart.googleapis.com/chart?cht=tx&chl=%24%5Chat%7Bg%7D%20%3D%20(%5Chat%7BV%7D%2C%20%5Chat%7BE%7D)%24 ---> substructure of https://chart.googleapis.com/chart?cht=tx&chl=%24g%24
  • https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bi%7D%20%5Cin%20V%24 ---> node
  • https://chart.googleapis.com/chart?cht=tx&chl=%24e_%7Bi%2Cj%7D%20%5Cin%20E%24 ---> 連接 https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bi%7D%24https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bj%7D%24 的邊
  • https://chart.googleapis.com/chart?cht=tx&chl=%24A%24 ---> https://chart.googleapis.com/chart?cht=tx&chl=%24g%24 的關聯矩陣
  • https://chart.googleapis.com/chart?cht=tx&chl=%24A_%7Bi%7D%24 ---> 關聯矩陣的第 https://chart.googleapis.com/chart?cht=tx&chl=%24i%24 row
  • https://chart.googleapis.com/chart?cht=tx&chl=%24A_%7Bi%2Cj%7D%24 ---> 關聯矩陣的第 https://chart.googleapis.com/chart?cht=tx&chl=%24i%24 row 第 https://chart.googleapis.com/chart?cht=tx&chl=%24j%24 column
  • https://chart.googleapis.com/chart?cht=tx&chl=%24f_v(v_i)%2C%20f_e(e_%7Bij%7D)%24 ---> node 或 edge 的類別
  • https://chart.googleapis.com/chart?cht=tx&chl=%24%5Cmathcal%7BT%7D%5Ev%2C%20%5Cmathcal%7BT%7D%5Ee%24 ---> node 或 edge 的類別的集合

First-order proximity https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7Bij%7D%5E%7B(1)%7D%20%3D%20A_%7Bi%2Cj%7D%24

是指計算 https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bi%7D%24https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bj%7D%24 之間邊的權重,也就是 https://chart.googleapis.com/chart?cht=tx&chl=%24A_%7Bi%2Cj%7D%24

https://ithelp.ithome.com.tw/upload/images/20230929/20132837P4u4iG0I8B.png

  • 像是上圖中的範例,https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7B1%7D%24https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7B2%7D%24 之間邊的權重為 1.2,所以 https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7B1%2C%202%7D%5E%7B(1)%7D%20%3D%201.2%24
  • https://chart.googleapis.com/chart?cht=tx&chl=%24v_1%24 與其他節點的權重的表達方式:https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7B1%7D%5E%7B(1)%7D%20%3D%20%5B0%2C%201.2%2C%200.8%2C%200%5D%24

Second-order proximity https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7Bi%2Cj%7D%5E%7B(2)%7D%24

簡單來說就是計算 https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bi%7D%24's neighbors 跟 https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bj%7D%24's neighbors 的相似度

所以 https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7Bi%2Cj%7D%5E%7B(2)%7D%24 的計算方式為:

  • https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7B1%7D%5E%7B(1)%7D%20%3D%20%5B0%2C%201.2%2C%200.8%2C%200%5D%24
  • https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7B2%7D%5E%7B(1)%7D%20%3D%20%5B1.2%2C%200%2C%201%2C%200%5D%24
  • https://chart.googleapis.com/chart?cht=tx&chl=%24S_%7B1%2C2%7D%5E%7B(2)%7D%20%3D%20cosin(S_%7B1%7D%5E%7B(1)%7D%2C%20S_%7B2%7D%5E%7B(1)%7D)%20%3D%200.36%24
import numpy as np

vec1 = np.array([0, 1.2, 0.8, 0])
vec2 = np.array([1.2, 0, 1, 0])

cos_sim = vec1.dot(vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2))

print(cos_sim)

>>> 0.3551104121142175

Higher-order proximity

如果是更高維度 https://chart.googleapis.com/chart?cht=tx&chl=%24k%24 的 proximity,就是去計算 https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bi%7D%24https://chart.googleapis.com/chart?cht=tx&chl=%24v_%7Bj%7D%24https://chart.googleapis.com/chart?cht=tx&chl=%24(k-1)%24 order 的相似度,用公式表示:https://chart.googleapis.com/chart?cht=tx&chl=%24cosine(S_%7Bi%7D%5E%7B(k-1)%7D%2C%20S_%7Bj%7D%5E%7B(k-1)%7D)%24

不過在更高維度的 proximity 上,使用的方法就不一定是計算 edge 的權重,也可以使用其他的 metric,例如:Katz index, rooted PageRank, Adamic-Adar index 等等。


上一篇
Day-13-Paper Reading -- Graph Embedding
下一篇
Day-15-Paper Reading -- Graph Embedding - 續
系列文
初探 Network Science30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言