Reading this book, I found the following description regarding model trees for numeric prediction, in which nominal attributes are transformed to binary attributes.
Before constructing a model tree, all nominal attributes are transformed into binary variables that are then treated as numeric. For each nominal attribute, the average class value corresponding to each possible value in the set is calculated from the training instances, and the values are sorted according to these averages. Then, if the nominal attribute has k possible values, it is replaced by k – 1 synthetic binary attributes, the ith being 0 if the value is one of the first i in the ordering and 1 other wise. Thus, all splits are binary: They involve either a numeric attribute or a synthetic binary attribute that is treated as numeric.
Well, I don't understand what it means. For example, suppose I have a Fruits attribute with several values such as Apple
, Orange
, Pear
with some numeric class C1
for each instance. I think that by average class value
that paragraph refers to the average in C1
for Apple
, Orange
, Pear
.
But then what is doing to convert those nominal attributes to binary and why does it take k possible values (in this case, k should be 3) and returns k-1 binary attributes?
By the way, it seems that the class NominalToBinary here does exactly that but I don't have weka installed nor I know how to use it. I also took the example using Fruits as attribute from here.
I would appreciate an explanation or an example.
Thanks a lot.