Using+the+MathExpression+filter

The filter can be found in this package: code format="text" weka.filters.unsupervised.attribute code It provides a powerful means of performing mathematical transformations of numeric attributes. The following operators are supported: code format="text" +, -, *, /,, pow, log, abs, cos, exp, sqrt, tan, sin, ceil, floor, rint, MEAN, MAX, MIN, SD, COUNT, SUM, SUMSQUARED, ifelse code The attribute value that is being processed, can be referenced as ****.

= Manual discretization = One can even use the filter for manually discretizing numeric attributes, if the other filters (supervised and unsupervised) cannot be used. This works thanks to the operator.

It is basically a two-step-process:
 * 1) run  to turn all the values into discrete ones
 * 2) run  to turn the numeric values then into nominal labels

Here's an example: code format="text" (-inf-20.0] (20.0-80.0] (80.0-inf) code code format="bash" weka.filters.unsupervised.attribute.MathExpression \ -E "ifelse(A>20, ifelse(A>80, 3, 2), 1)" \ -V \ -R 1 code > **Note:** means we only want to transform the first attribute. Without all the numeric attributes would be transformed according to this expression. code format="text" (-inf-20.0] -> 1 (20.0-80.0] -> 2 (80.0-inf) -> 3 code code format="bash" weka.filters.unsupervised.attribute.NumericToNominal \ -R 1 code
 * a dataset where the first attribute needs to be discretized into 3 bins
 * the bins need to be as follows
 * using to create discrete values
 * this results in the following transformation
 * using to create a nominal attribute from the numeric one
 * //optional:// if one wants to rename those labels, one can use the class listed in the Rename Attribute Values article for that


 * Note:** the "\" at the end of the lines tell a *nix [|bash] to continue on the next line.