매개 중심성
리트윗 및 답글 네트워크의 매개 중심성은 서로 다른 Twitter 커뮤니티 사이를 이어 주는 사용자를 보여줍니다. 이런 커뮤니티는 주제나 이념으로 연결되어 있을 수 있어요.
networkx는 nx로 임포트되어 있습니다.
네트워크 G_rt와 G_reply, 그리고 column_names = ['screen_name', 'betweenness_centrality']가 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Python으로 소셜 미디어 데이터 분석하기
연습 안내
nx.betweenness_centrality()를 사용해 리트윗 네트워크의 매개 중심성을 계산하세요.- 답글 네트워크도 동일하게 계산하세요.
- 리트윗 매개 중심성으로 DataFrame을 만드세요.
- 답글 네트워크도 동일하게 만드세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Generate betweenness centrality for retweets
rt_centrality = ____
# Generate betweenness centrality for replies
reply_centrality = ____
# Store centralities in data frames
rt = pd.DataFrame(____, ____ = ____)
reply = pd.DataFrame(____, ____ = ____)
# Print first five results in descending order of centrality
print(rt.sort_values('betweenness_centrality', ascending = False).head())
# Print first five results in descending order of centrality
print(reply.sort_values('betweenness_centrality', ascending = False).head())