filter - 在 Weka 中使用 AddExpression/MathExpression

标签 filter attributes preprocessor weka

我正在处理一个非常基本的 WEKA 作业,我正在尝试使用 WEKA 预处理来自 GUI(最新版本)的数据。双击 MathExpression 时,我试图在表达式框中执行非常基本的 if 语句和数学语句,但没有取得任何成功。比如我想做

if (a5 == 2 || a5 == 0) then y = 1; else y = 0

这个的许多不同变体对我没有用,我也不清楚如何引用“y”或者它是否需要在行内引用。

另一个例子是 -abs(log(a7)–3) 我也没能算出来。关于如何使这些语句起作用的任何想法?

最佳答案

来自 MathExpression 的 javadoc

The 'A' letter refers to the value of the attribute being processed. Other attribute values (numeric only) can be accessed through the variables A1, A2, A3, ...

您的过滤器适用于数据集的所有属性。如果我加载 iris 数据集并应用以下过滤器。

weka.filters.unsupervised.attribute.MathExpression -E log(A).

您的属性,sepallength 值更改如下。

Before Filter      After Filter           
Minimum 4.3    Minimum  1.459
Maximum 7.9    Maximum  2.067
Mean    5.843  Mean 1.755
StdDev  0.828  StdDev   0.141

此外,如果您查看 javadoc,则没有 if else 函数,只有 ifelse 函数。因此你应该写类似的东西

ifelse ( (A == 2 || A == 0), 1,0 ) 

此过滤器也适用于所有属性。如果只想更改一个属性并根据其他属性值;那么你需要使用“忽略范围选项”并使用A1,A2来引用其他属性值。

如果您需要添加新属性,请使用 AddExpression .

An instance filter that creates a new attribute by applying a mathematical expression to existing attributes.

关于filter - 在 Weka 中使用 AddExpression/MathExpression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12292589/

相关文章:

Python Selenium - 属性错误 : WebElement object has no attribute sendKeys in textarea

ios - 在 Xcode 9 中实现预处理器?

python - 替换所有连续重复的字母忽略特定单词

python - 根据Python中的值查找第一行文本

angularjs - ng-options 和唯一过滤器不显示 angular.js

ios - 如果使用核心数据,应用程序会崩溃

spring-mvc - 具有 session 属性的 mvc Controller 测试

c - 为什么预处理器不将回车符视为空白字符

javascript - 删除特定参数

java - 在 FileSystem.liststatus 中过滤日志文件(_success 和 _log)