【问题标题】:Get list of features correlated with target variable获取与目标变量相关的特征列表
【发布时间】:2020-05-03 17:46:06
【问题描述】:

我正在尝试获取大于 0.15 的数据集的特征列表 它的代码让我这样做,但我有一个意甲熊猫,我无法检索列表中的列名 在我的数据集中删除它们之后。 感谢您的帮助。

# Remove highly correlated features
cor = features_binario.corr()
#Correlation with output variable
cor_target = abs(cor["G3"])

#Selecting highly correlated features
relevant_features = cor_target[cor_target>0.15]

first_column = relevant_features.iloc[:,0]
first_column

我收到此错误,IndexingError: Too many indexers

Var: relevant_features
school_GP      0.177564
school_MS      0.177564
higher_no      0.251587
higher_yes     0.251587
course_math    0.168394
course_por     0.168394
age            0.153819
Medu           0.184047
Fedu           0.183627
failures       0.390165
G1             0.701693
G2             0.717439
G3             1.000000
Name: G3, dtype: float64

【问题讨论】:

  • print (relevant_features.info()) 是什么?
  • AttributeError: 'Series' 对象没有属性 'info'

标签: python pandas correlation


【解决方案1】:

它是Series,所以没有列。

按条件使用所有值:

relevant_features = cor_target.index[cor_target>0.15]

【讨论】:

  • 我得到 0.17756387716348085 这是价值
  • 它接近我得到“school_GP”
  • @Fernando - 预期输出是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-09
  • 2019-08-02
  • 2019-11-20
  • 2020-03-06
  • 2020-11-09
  • 2018-07-19
相关资源
最近更新 更多