반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

numpy.corrcoef 본문

[IT]/python.numpy

numpy.corrcoef

givemebro 2020. 4. 27. 10:22
반응형
import numpy as np
import matplotlib.pyplot as plt

from sklearn.datasets import load_breast_cancer

cancer = load_breast_cancer()

X=cancer.data
y=cancer.target

plt.scatter(X[:,0],X[:,2])
plt.axis('equal')

np.corrcoef(X[:,0],X[:,2])

 

array([[1.        , 0.99785528],
       [0.99785528, 1.        ]])

 

mat=np.corrcoef(X.T)
mat

plt.imshow(mat,vmin=-1,vmax=1,cmap='bwr')
plt.colorbar()

idx = [0, 2, 3, 12, 13, 20, 22, 23, 1, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 21, 24, 25, 26, 27, 28, 29]


X2 = X[:,idx]

mat = np.corrcoef(X2.T)

plt.imshow(mat, vmin=-1, vmax=1, cmap='bwr')
plt.xticks(range(30),idx,rotation=90)
plt.yticks(range(30),idx)
plt.colorbar()

반응형

'[IT] > python.numpy' 카테고리의 다른 글

np.moveaxis  (0) 2020.05.13
numpy.score  (0) 2020.05.12
numpy.where.3단 논법  (0) 2020.04.23
numpy.브로드캐스팅  (0) 2020.03.30
numpy.무한대 처리  (0) 2020.03.30
numpy.스칼라 연산  (0) 2020.03.30
numpy.file open  (0) 2020.03.27
numpy.reshape(차원 변경)  (0) 2020.03.26
Comments