Betweenness Centrality
Betweenness centrality ในเครือข่าย retweet และ reply ช่วยระบุผู้ใช้ที่ทำหน้าที่เชื่อมโยงชุมชนต่าง ๆ บน Twitter เข้าด้วยกัน ซึ่งชุมชนเหล่านี้อาจมีความสัมพันธ์กันผ่านหัวข้อหรืออุดมการณ์ที่คล้ายกัน
มีการ import networkx ให้แล้วในชื่อ nx
โหลดเครือข่าย G_rt และ G_reply รวมถึง column_names = ['screen_name', 'betweenness_centrality'] ให้แล้วเรียบร้อย
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python
คำแนะนำการฝึกหัด
- คำนวณ betweenness centrality สำหรับเครือข่าย retweet โดยใช้
nx.betweenness_centrality() - ทำแบบเดียวกันสำหรับเครือข่าย reply
- สร้าง DataFrame จากค่า centrality ของ retweet
- ทำแบบเดียวกันสำหรับเครือข่าย reply
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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())