Bipartite graphs and recommendation systems

Intermediate Network Analysis in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Recommendation systems

  • Previously: Recommended users to connect with one another
  • Graph: "unipartite" (or users-only) version
  • Now: "bipartite" or (repo-users) version
  • Recommending repositories for users to work on
Intermediate Network Analysis in Python

Recommendation systems

ch1-3.007.png

Intermediate Network Analysis in Python

Recommendation systems

ch1-3.008.png

Intermediate Network Analysis in Python

Recommendation systems

ch1-3.009.png

Intermediate Network Analysis in Python

Code: Node sets

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')]
Intermediate Network Analysis in Python

Code: Node sets

user1_nbrs = G.neighbors('user1')

user1_nbrs
['repo2']
user3_nbrs = G.neighbors('user3')
user3_nbrs
['repo2', 'repo1']
Intermediate Network Analysis in Python

Code: Node sets

set(user1_nbrs).intersection(user3_nbrs)
{'repo2'}
set(user3_nbrs).difference(user1_nbrs)
{'repo1'}
Intermediate Network Analysis in Python

Let's practice!

Intermediate Network Analysis in Python

Preparing Video For Download...