二分圖與推薦系統

Python 網路分析進階

Eric Ma

Data Carpentry instructor and author of nxviz package

推薦系統

  • 前面:推薦使用者彼此連結
  • 圖:單分圖(僅使用者)版本
  • 現在:二分圖(repo-users)版本
  • 為使用者推薦可參與的儲存庫
Python 網路分析進階

推薦系統

ch1-3.007.png

Python 網路分析進階

推薦系統

ch1-3.008.png

Python 網路分析進階

推薦系統

ch1-3.009.png

Python 網路分析進階

程式碼:節點集合

list(G.nodes(data=True))
[('repo3', {'bipartite': 'repositories'}),
 ('repo1', {'bipartite': 'repositories'}),
 ('user1', {'bipartite': 'users'}),
 ('user2', {'bipartite': 'users'}),
 ('repo2', {'bipartite': 'repositories'}),
 ('user3', {'bipartite': 'users'})]
list(G.edges())
[('repo1', 'user3'),
 ('user1', 'repo2'),
 ('user2', 'repo2'),
 ('repo2', 'user3')]
Python 網路分析進階

程式碼:節點集合

user1_nbrs = G.neighbors('user1')

user1_nbrs
['repo2']
user3_nbrs = G.neighbors('user3')
user3_nbrs
['repo2', 'repo1']
Python 網路分析進階

程式碼:節點集合

set(user1_nbrs).intersection(user3_nbrs)
{'repo2'}
set(user3_nbrs).difference(user1_nbrs)
{'repo1'}
Python 網路分析進階

一起來練習吧!

Python 網路分析進階

Preparing Video For Download...