如何使用RWeka分类器函数属性"options"?

How to use RWeka classifiers function attribute "options"?

在RWeka分类器中,分类器的函数调用中有一个属性"options",例如 Bagging(formula, data, subset, na.action, control = Weka_control(),选项 = NULL)。有人可以举一个例子(一个示例 R 代码)来说明如何定义这些选项吗?

我有兴趣将一些选项(例如迭代次数和每个包的大小)传递给 RWeka 的 Bagging 元学习器。提前致谢!

您可以获取您提到的功能,但不能通过 options

首先,选项有什么作用?根据帮助页面 ?Bagging

Argument options allows further customization. Currently, options model and instances (or partial matches for these) are used: if set to TRUE, the model frame or the corresponding Weka instances, respectively, are included in the fitted model object, possibly speeding up subsequent computations on the object. By default, neither is included.

所以选项只是在返回的结果中存储了更多的信息。要获得您想要的功能,您需要使用 control。您需要使用函数 Weka_control 构造 control 的值。没有一些帮助,很难知道如何使用它,但幸运的是,可以通过 WOW Weka 选项向导获得帮助。因为有很多选项,所以输出很长。我将把它截断为关于您提到的功能的部分 - 每个包的迭代次数和大小。但是请看看还有什么可用的。

WOW(Bagging)
-P      Size of each bag, as a percentage of the training set size. (default 100)
-I <num>
        Number of iterations.  (current value 10)
        Number of arguments: 1.

重复:我截断了输出以仅显示这两个选项。

示例:虹膜数据

假设我想对 iris 数据使用装袋,袋大小为数据的 90%(而不是默认的 100%),迭代次数为 20 次(而不是默认的 10 次)。首先,我将构建 Weka_control,然后将其包含在对 Bagging.

的调用中
WC = Weka_control(P=90, I=20) 
BagOfIrises = Bagging(Species ~ ., data=iris, control=WC)

希望对您有所帮助。