二部グラフとレコメンダーシステム

Python 中級ネットワーク解析

Eric Ma

Data Carpentry instructor and author of nxviz package

レコメンダーシステム

  • これまで:ユーザー同士の接続を推薦
  • グラフ:単一部(ユーザーのみ)版
  • これから:二部(リポジトリ×ユーザー)版
  • ユーザーに作業先のリポジトリを推薦
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 中級ネットワーク解析

Let's practice!

Python 中級ネットワーク解析

Preparing Video For Download...