<jupyter_start><jupyter_text>Key Data Figures from the Network<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Load edge list
file = '../data/output/Email_Network_Stats.xlsx'
stats_list = pd.read_excel(file) 
stats_list.set_index('Senders')
# Degree Visualization
num_bins=25
plt.hist(stats_list['Degree'], num_bins)
plt.axvline(x=stats_list['Degree'].mean(), color='red', label='Average degree')
plt.legend(loc='upper right')
plt.xlabel('Node Degree')
plt.ylabel('Number of nodes')

file='../image/Email_degree.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.show()
# Top 15 most connected people
top_people=stats_list.sort_values(by='Degree', ascending=False).head(15)
top_people.set_index('Senders')
# Assortativity
df_assort= stats_list[['Senders','Degree','Neighbour Degree']]
df_assort.set_index('Senders')
df_assort_av=pd.DataFrame(df_assort['Neighbour Degree'].groupby(df_assort['Degree']).mean())
file='../image/Email_assortativity.png'
plt.scatter(df_assort['Degree'], df_assort['Neighbour Degree'])
plt.plot(df_assort_av.index, df_assort_av['Neighbour Degree'], color='black', label='Average')
plt.axvline(x=stats_list['Degree'].mean(), color='red', label='Average degree of graph')
plt.xlabel('Node degree')
plt.ylabel('Average degree of neighbours')
plt.legend(loc='upper right')
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.show()
#Clustering
df_cluster_node= stats_list[['Senders','Degree','Clustering']]
df_assort.set_index('Senders')

plt.axhline(y=stats_list['Clustering'].mean(), color='red', label='Average Clustering Coeficient')
plt.legend(loc='upper right')

file='../image/Email_clustering.png'
plt.scatter(df_cluster_node['Degree'], df_cluster_node['Clustering'])
plt.xlabel('Node degree')
plt.ylabel('Average clustering coefficient')
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.show()<jupyter_output><empty_output><jupyter_text>Check --> probably due to stuctural reasons: different departments, chain of comand...<jupyter_code># Eccentricity
min_eccentricity = stats_list['Eccentricity'].min()
max_eccentricity = stats_list['Eccentricity'].max()

df_eccen_8 = len(stats_list['Senders'][stats_list['Eccentricity']==8])
df_eccen_7 = len(stats_list['Senders'][stats_list['Eccentricity']==7])
df_eccen_6 = len(stats_list['Senders'][stats_list['Eccentricity']==6])
df_eccen_5 = len(stats_list['Senders'][stats_list['Eccentricity']==5])
print(
    "ECCENTRICITY" + '\n'
        "The minimun eccentricity is: " + str(min_eccentricity) + "\n"
        "The maximum eccentricity / Diameter of the Network is: " + str(max_eccentricity) + "\n"
        "There is " + str(df_eccen_8) +" nodes with an eccentricity of 8\n"
        "There is " + str(df_eccen_7) +" nodes with an eccentricity of 7\n"
        "There is " + str(df_eccen_6) +" nodes with an eccentricity of 6\n"
        "There is " + str(df_eccen_5) +" nodes with an eccentricity of 5\n"
        "Total of nodes: " + str(df_eccen_8 + df_eccen_7 + df_eccen_6 + df_eccen_5)
    )

plt.scatter(stats_list['Degree'], stats_list['Eccentricity'])
plt.xlabel('Node degree')
plt.ylabel('Eccentricity')
# Centrality measures
# Degree Centrality
deg_cent=stats_list['Degree Centrality'].mean()
num_bins=25
plt.hist(stats_list['Degree Centrality'], num_bins)
plt.axvline(x=deg_cent, color='red')
plt.xlabel('Degree Centrality')
plt.ylabel('Number of nodes')
file='../image/Email_degree_centrality.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
# Closeness Centrality
clos_cent=stats_list['Closeness'].mean()
num_bins=25
plt.hist(stats_list['Closeness'], num_bins)
plt.axvline(x=clos_cent, color='red')
plt.xlabel('Closeness')
plt.ylabel('Number of nodes')
file='../image/Email_closeness_centrality.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.scatter(stats_list['Degree'], stats_list['Closeness'])
plt.xlabel('Node degree')
plt.ylabel('Closeness centrality')
file='../image/Email_closeness_to_degree.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
# Betweeness Centrality
bet_cent=stats_list['Betweeness'].mean()
num_bins=25
plt.hist(stats_list['Betweeness'], num_bins)
plt.axvline(x=bet_cent, color='red')
plt.xlabel('Betweeness')
plt.ylabel('Number of nodes')
file='../image/Email_betweeness_centrality.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.scatter(stats_list['Degree'], stats_list['Betweeness'])
plt.xlabel('Node degree')
plt.ylabel('Betweeness')
file='../image/Email_betweeness_to_degree.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
#Random Walk Centrality
rw_cent=stats_list['RandomWalk'].mean()
num_bins=25
plt.hist(stats_list['RandomWalk'], num_bins)
plt.axvline(x=rw_cent, color='red')
plt.xlabel('Random Walk')
plt.ylabel('Number of nodes')
file='../image/Email_RandomWalk_centrality.png'
plt.savefig(file, bbox_inches='tight', dpi=200)
plt.scatter(stats_list['Degree'], stats_list['RandomWalk'])
plt.xlabel('Node degree')
plt.ylabel('RandomWalk')
file='../image/Email_RandomWalk_to_degree.png'
plt.savefig(file, bbox_inches='tight', dpi=200)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16590864148704765, 'fraction_numerical': 0.01265572473798695, 'mean_word_length': 8.032142857142857, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '445409', 'license': 'MIT', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1884, 'n_words': 300, 'path': 'jupyter-notebook/Email_Data_Visualization.ipynb', 'repo_name': 'Rjfmade/Email-Network-Analysis', 'size': '5057'}