【问题标题】:Correlation matrix does not show all columns python相关矩阵不显示所有列python
【发布时间】:2019-07-15 09:51:04
【问题描述】:

我正在尝试解决来自 Kaggle 的“房价”挑战,但我被困在我的相关矩阵上,因为它根本没有显示我想要的所有列。最初,显然是因为列数较多,所以我这样做了:

df = df_data[['SalePrice', 'MSSubClass', 'MSZoning', 'LotFrontage', 'LotArea', 'Street', 'Alley', 'LotShape', 'LandContour', 'Utilities']].copy()    

corrmax = df.corr()

f, ax = plt.subplots(figsize=(16,12))
sns.heatmap(corrmax, annot = True)

然后,由于某种原因,结果是只有 SalePrice、MSSubClass、LotFrontage 和 LotArea 的热图。谁能帮帮我?

【问题讨论】:

  • 也许您的某些列不是数字的?试试print(df.dtypes)看看。
  • 哎哟!他们不是!既然你这么说,那就太傻了!哈哈!谢谢!

标签: python pandas seaborn heatmap


【解决方案1】:

如果您分析房价House Prices 的数据集,则大约有 21-23 个分类变量 'MSZoning'、'Alley' corr() 矩阵只显示它们在数值或非分类变量之间的关系

corrmax = df.corr()

如果你想找到分类变量和非分类变量之间的关系需要使用Spearman correlation matrix

您可以从下面的链接中找到一些帮助...

An overview of correlation measures between categorical and continuous variables

Correlation between a nominal (IV) and a continuous (DV) variable

【讨论】:

    猜你喜欢
    • 2020-07-24
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 2019-06-16
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多