import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy import stats
train_data='zhengqi_train.txt'
test_data='zhengqi_test.txt'
train=pd.read_csv(train_data,sep='\t',encoding='utf-8')
test=pd.read_csv(test_data,sep='\t',encoding='utf-8')
train.drop(['V5','V9','V11','V17','V22','V28'],axis=1)
co=train.corr()
print(co.nlargest(10,'target'))#输出与target相关系数大于10的特征。满足要求指定行和所有列。
print(co.nlargest(10,'target')['target'])#在上一条基础上取出target列
cols=co.nlargest(10,'target')['target'].index#在列上输出索引。
import numpy as np
sns.heatmap(train[cols].corr())#有了列输出特征。
plt.show()
标签:co,target,heatmaps,特征,相关系数,train,test,import,data From: https://www.cnblogs.com/hahaah/p/16965783.html