[英]Errors on graph for matplot correlation
I am unable to get the correlation matrix to work.我无法使相关矩阵起作用。
import pandas as pd
import matplotlib.pyplot as plt
info = pd.read_csv('https://raw.githubusercontent.com/tofighi/MachineLearning/master/datasets/heart.csv');
#Percentage of 0 and 1
percentage = info['chd'].value_counts(normalize=True)
print(info['chd'].value_counts())
print(percentage)
#Missing values
print('\nNumber of missing values:')
print(info.isnull().sum())
#Categorical Variables
print('\n')
print(info.info())
#Maximum Correlation
f = plt.figure(figsize=(19, 15))
plt.matshow(info.corr(), fignum=f.number)
plt.xticks(range(info.shape[1]), info.columns, fontsize=14, rotation=90)
plt.yticks(range(info.shape[1]), info.columns, fontsize=14)
cb = plt.colorbar()
cb.ax.tick_params(labelsize=14)
plt.title('Correlation Matrix', fontsize=16)
plt.show()
Error错误
KeyError: (0.0, 0.0, 'row.names', 'black', 'center_baseline', 'right', 4543961435493219500, None, None, 72.0, <weakref at 0x7f25554ca548; dead>, 1.2)
I had to reconnect to hosted runtime and that seemed to fix the problem.我不得不重新连接到托管运行时,这似乎解决了问题。 There is a drop down menu besides the ram/disk where you can click to connect to hosted runtime.
除了 ram/disk 之外还有一个下拉菜单,您可以在其中单击以连接到托管运行时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.