데이터셋 소개

Python 중급 네트워크 분석

Eric Ma

Data Carpentry instructor and author of nxviz package

데이터셋 및 사례 연구 소개

  • 대학 포럼 게시물 데이터셋, 6개월
  • 노드 파티션: 학생, 포럼
  • 챕터 활동:
    • pandas DataFrame으로 그래프 구성
    • 이분 그래프의 단일 파티션 투영 계산
    • 시각화
    • 시계열 필터링 및 분석
  • 이전에 사용한 함수 복습
Python 중급 네트워크 분석

DataFrame으로 그래프 만들기

df
   customers    products
0  customerA    product1
1  customerB    product2
...
G = nx.Graph()

G.add_nodes_from(df['products'], bipartite='products') G.add_nodes_from(df['customers'], bipartite='customers')
list(G.nodes())
['product1', 'customerC', 'product2', 'customerB', 'customerA']
list(G.edges())
[]
Python 중급 네트워크 분석

DataFrame으로 그래프 만들기

G.add_edges_from(zip(df['customers'], df['products']))

list(G.edges())
[('product1', 'customerC'), ('product1', 'customerA'), 
    ('customerC', 'product2'), ('product2', 'customerB')]
Python 중급 네트워크 분석

이분 그래프 투영

cust_nodes = [n for n in G.nodes() if G.nodes[n]
                 ['bipartite'] == 'customers']

prod_nodes = [n for n in G.nodes() if G.nodes[n] ['bipartite'] == 'products']
prodG = nx.bipartite.projected_graph(G, nodes=prod_nodes) custG = nx.bipartite.projected_graph(G, nodes=cust_nodes)
list(prodG.nodes())
['product1', 'product2']
list(custG.nodes())
['customerC', 'customerB', 'customerA']
Python 중급 네트워크 분석

연습해 봅시다!

Python 중급 네트워크 분석

Preparing Video For Download...