SHARE
TWEET

Untitled

a guest May 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4.  
  5. from scipy.stats import pearsonr
  6.  
  7.  
  8. def main():
  9.     data = pd.read_csv('engineer.csv')
  10.     colX=['Atmosphere', 'lecture quality', 'paper supporting', 'payment',
  11.        'personality']
  12.     colY=[ 'N corresponding author', 'citation index', 'alumni',
  13.        'alumni(dr)', 'alumni(ms)', 'avg semesters(dr)']
  14.  
  15.     dataX=data[colX]
  16.     dataY=data[colY]
  17.  
  18.     #print(dataX)
  19.     #corr = dataX.corrwith(dataY)
  20.     corr= pd.concat([dataX, dataY], axis=1).corr()
  21.     corr = corr[colY].ix[colX]
  22.     print(corr)
  23.     fig = plt.figure()
  24.     ax = fig.add_subplot(111)
  25.     cax = ax.matshow(corr, cmap='coolwarm', vmin=-1, vmax=1)
  26.     fig.colorbar(cax)
  27.     xticks=np.arange(6)
  28.     yticks=np.arange(5)
  29.  
  30.     ax.set_xticks(xticks)
  31.     plt.xticks(rotation=90)
  32.     ax.set_yticks(yticks)
  33.     ax.set_xticklabels(colY)
  34.     ax.set_yticklabels(colX)
  35.     print(corr.columns)
  36.     plt.show()
  37.     corr.to_csv("correlation.csv", mode='w')
  38. if __name__ =='__main__':
  39.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top