Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arimitramaiti/237ee1b58590e0f8a1e2871ee4a37155 to your computer and use it in GitHub Desktop.
Save arimitramaiti/237ee1b58590e0f8a1e2871ee4a37155 to your computer and use it in GitHub Desktop.
Correlation Matrix of Centrality Scores Mumbai Local Network
##Import required modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import scipy.stats as stats
import math
##Read the centrality scores generated from empirical network of mumbai local rail
url = "https://raw.githubusercontent.com/arimitramaiti/datasets/master/articles/mumbai_local_centrality_scores.csv"
dataset = pd.read_csv(url, error_bad_lines=False, header=0, index_col=None)
dataset.head(4)
##Generate correlation matrix
fig, ax = plt.subplots(1, 1, figsize=(12, 5))
cormat = dataset.iloc[: , 2:6].corr()
sns.heatmap(cormat,
cmap=sns.color_palette("Blues"),
fmt='.1g',
annot = True,
vmin=-1, vmax=1, center= 0,
linewidths=2, linecolor='black',
square=True,
mask=np.triu(cormat),
ax=ax)
ax.set_title('Correlation Matrix of Centrality Measures', fontsize=12, pad=30)
fig.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment