यूज़र नोड्स की डिग्री सेंट्रेलिटी डिस्ट्रीब्यूशन
इस अभ्यास और अगले में, आप पिछले कोर्स के सामग्री का अंतिम रिकैप करेंगे. आपका काम GitHub collaboration नेटवर्क के bipartite वर्ज़न में प्रत्येक node partition के लिए degree centrality डिस्ट्रीब्यूशन plot करना है. यहाँ, आप यह 'users' partition के लिए करेंगे. अगले अभ्यास में, आप यह 'projects' partition के लिए करेंगे.
जो फंक्शन आपने पहले लिखा था, get_nodes_from_partition(), वह आपके लिए लोड कर दिया गया है. याद दिलाने के लिए, "degree centrality" node की महत्ता का एक माप है, और "degree centrality distribution" ग्राफ के सभी nodes के degree centrality स्कोरों की सूची होती है. कुछ अभ्यास पहले, जब आपने circos plot बनाया था, तब हमने आपके लिए degree centralities compute की थीं. अब आप यह काम स्वयं करके अभ्यास करेंगे!
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Network Analysis in Python
अभ्यास निर्देश
matplotlib.pyplotकोpltनाम से import करें.- पिछले अभ्यास के अपने
get_nodes_from_partition()फंक्शन का उपयोग करकेGके'users'nodes के अनुरूपuser_nodesनाम की एक सूची प्राप्त करें. nx.degree_centrality()फंक्शन का उपयोग करते हुए,Gके प्रत्येक node की degree centrality compute करें. परिणाम कोdcsके रूप में सहेजें.- एक list comprehension का उपयोग करके,
user_nodesके प्रत्येक node की degree centrality निकालें. परिणाम कोuser_dcsके रूप में सहेजें.- याद रखें,
dcsएक dictionary है, जिसमें keys nodes होते हैं. यहाँ प्रासंगिक nodesuser_nodesमें हैं. आप इस जानकारी का उपयोग करके user nodes की degree centralities कैसे प्राप्त करेंगे? अपने iterator variable के रूप मेंnका उपयोग करें.
- याद रखें,
plt.hist()औरuser_dcsका उपयोग करके users की degree distribution का histogram plot करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import matplotlib
____
# Get the 'users' nodes: user_nodes
user_nodes = ____
# Compute the degree centralities: dcs
dcs = ____
# Get the degree centralities for user_nodes: user_dcs
user_dcs = [dcs[____] for n in ____]
# Plot the degree distribution of users_dcs
plt.yscale('log')
plt.hist(____, bins=20)
plt.show()