ml3filters 中的 AUC 过滤器

AUC filter in ml3filters

我尝试更多地了解mlr3filters的AUC过滤器。我使用 classification 任务 (task) 和以下代码:

filter = flt("auc")

filter$calculate(task)

result<-as.data.table(filter)

根据 mlr3measures::auc() 中的文档,我了解到我需要一个概率向量和一个具有(二进制)因子值的向量以及“真”class。在我的任务中,我有二进制 class (作为“目标”)和许多数字特征,但 not 在 0 和 1 之间,所以我不能将它们解释为可能性。 那为什么要计算AUC呢?还是有额外的假设?我的问题是我无法从 filter$help().

读取此内容

作为一般性问题:https://mlr3filters.mlr-org.com/reference/index.html 中的函数引用和底层 R 函数之间是否有额外的“解释层”?例如,我知道 FilterVariance$new() 生成一个过滤器对象,该对象通过 仅使用这些特征 并应用 stats::var() 来计算单个特征的方差。但是从书中,我也看到我可以指定截止值:

po("filter", mlr3filters::FilterVariance$new(), filter.frac = 0.5)

在哪里可以找到有关此 filter.frac 值的详细信息?我在 filter$help() 中找不到它,在 stats::var()

中也找不到

同样,我了解到 FilterCorrelation$new() 生成一个过滤器对象,该对象采用单个特征 和目标 来计算特征等级。这可能是不言自明的,但我想知道在哪里可以找到有关此类问题的更多详细信息。

我尝试了在此处 () 找到的答案,但我无法在 filter$help()

中找到详细信息

在此先感谢初学者$help()

虽然 AUC 过滤器的文档声明它类似于 mlr3measures::auc,但它实际上并没有使用该功能。相反,它使用它的own implementation which calculates the Area Under the ("Receiver Operating Characteristic") Curve,它不需要概率值,只需要一个连续的值,可以用一个截止值来划分样本。

据我了解,Filters 主要用于计算过滤器分数(请参阅 documentation of the Filter base class). They are mostly useful in combination with the PipeOpFilter from the mlr3pipelines package, which is also what the example from the book that you cite is doing. PipeOps are generally useful to integrate a filtering step (or any kind of preprocessing) into a learning process (the book chapter on mlr3pipelines 可能是了解它的一个好点)。然而,这些也可以用于计算步骤,例如从 Task:

中过滤出列
pof = po("filter", mlr3filters::FilterVariance$new(), filter.frac = 0.5)
task = tsk("iris")
pof_result = pof$train(list(task))
pof_result[[1]]
#> <TaskClassif:iris> (150 x 3)
#> * Target: Species
#> * Properties: multiclass
#> * Features (2):
#>   - dbl (2): Petal.Length, Sepal.Length
pof_result[[1]]$data()
#>        Species Petal.Length Sepal.Length
#>   1:    setosa          1.4          5.1
#>   2:    setosa          1.4          4.9
#>   3:    setosa          1.3          4.7
#>   4:    setosa          1.5          4.6
#>   5:    setosa          1.4          5.0
#>  ---                                    
#> 146: virginica          5.2          6.7
#> 147: virginica          5.0          6.3
#> 148: virginica          5.2          6.5
#> 149: virginica          5.4          6.2
#> 150: virginica          5.1          5.9

参见 ?PipeOp about the $train() method (although really the book chapter is a better place to start imho). The ?PipeOpFilter 文档 filter.frac 超参数:

Parameters:

[...]

   • ‘filter.nfeat’ :: ‘numeric(1)’
     Number of features to select. Mutually exclusive with ‘frac’
     and ‘cutoff’.

   • ‘filter.frac’ :: ‘numeric(1)’
     Fraction of features to keep. Mutually exclusive with ‘nfeat’
     and ‘cutoff’.

   • ‘filter.cutoff’ :: ‘numeric(1)’
     Minimum value of filter heuristic for which to keep features.
     Mutually exclusive with ‘nfeat’ and ‘frac’.

Note that at least one of ‘filter.nfeat’, ‘filter.frac’, or
‘filter.cutoff’ must be given.

所以它所做的是 运行 Filter$calculate() 函数和 select 基于结果 $score 的特征。

回答关于从哪里获得帮助的更一般的问题:通常对象 类(您通常可以通过调用 class(object) 找到它)是一个很好的开始。通常这些 类 继承自更通用的基础 类,如果他们不熟悉,这些基础也会解释过程的某些部分。在本例中,PipeOpFilter inherits from several classes, among them PipeOp——这在帮助文件中有说明。除此之外,还有你知道的那本书。最后,如果一切都失败了,不幸的是,可能有必要查看源代码。