【问题标题】:How to select only the best features by setting up the threshold using FSelector information gain in R language?如何通过使用 R 语言中的 FSelector 信息增益设置阈值来仅选择最佳特征?
【发布时间】:2017-11-10 21:01:31
【问题描述】:

我已经通过在 R 中使用 FSelector 包在 R 中完成了信息增益特征选择

install.packages("RWekajars")
install.packages("FSelector")
library(FSelector)

weights <- information.gain(Classname~., df)

Attributes                                          attr_importance
X.1                                              3.6349780
X                                                3.6349780
Value_1                                          3.7128973
Value_1                                          0.9652070
Item_1                                           2.0845525

现在,我需要根据 attr_importance 从中选择最佳功能。如何根据阈值选择R中最好的特征以及如何设置阈值?

【问题讨论】:

  • weights$Attributes[weights$attr_importance &gt; threshold]

标签: r information-gain fselector


【解决方案1】:

FSelector 包中有一个方法cutoff.k 可以解决您的问题:

  • cutoff.k 选择 k 个最佳属性
  • cutoff.k.percent 选择最佳 k * 100% 的属性
  • cutoff.biggest.diff 选择一个明显优于其他属性的子集。

例如:results &lt;- cutoff.k.percent(weights, 0.9) 将返回所有属性,直到达到 0.9。 或者:results &lt;- cutoff.k(weights, 2) 将返回信息增益最多的 2 个属性。 这能解决您的问题吗?

【讨论】:

    猜你喜欢
    • 2021-01-28
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 2016-01-30
    • 2020-07-07
    • 2018-08-26
    • 2023-03-30
    • 2019-05-17
    相关资源
    最近更新 更多