观察特征的分布

1 连续和离散特征

若数据本身没有处理过离散特征(数字化),可用

numeric_features = Train_data.select_dtypes(exclude='object')
category_features = Train_data.select_dtypes(include='object')

否则需要手工挑选出连续的和离散的特征

2 数字(连续)特征

与目标值关系

corr = Train_data[numeric_features].corr()
print(corr['price'].sort_values(ascending=False))

特征间关系

plt.figure(figsize=(7, 7))
sns.heatmap(corr, square=True)

特征的峰度和偏度

for col in numeric_features:
    print('{:15}'.format(col), 
          'Skewness: {:05.2f}'.format(Train_data[col].skew()) , 
          '   ' ,
          'Kurtosis: {:06.2f}'.format(Train_data[col].kurt())  
         )

3 类别(离散)特征

可以通过 boxplot、violinplot 观察

猜你喜欢

转载自blog.csdn.net/qq_40860934/article/details/114286821