4
$\begingroup$

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.

$\endgroup$

1 Answer 1

4
$\begingroup$

Here's how the binary values for Apple, Orange and Pear are calculated. You know it has two binary digits (since k=3 and it has k-1 digits), so you compute each of those two digits:

  • Apple is one of the first 1 in the ordering, so its first digit is 1. Apple is one of the first 2 in the ordering, so its second digit is 1.

  • Orange is not one of the first 1 in the ordering, so its first digit is 0. Orange is one of the first 2 in the ordering, so its second digit is 1.

  • Pear is not one of the first 1 in the ordering, so its first digit is 0. Pear is not one of the first 2 in the ordering, so its second digit is 0.

Thus, they are translated into: 11, 01, 00.

If you had 10 attributes, they would become:

111111111, 011111111, 001111111, 000111111, 000011111, 000001111,
000000111, 000000011, 000000001, 000000000
$\endgroup$
4
  • $\begingroup$ Excellent answer. This is assuming that the ordering of Apple, Orange, and Pear is given according to the average of C1 (the class of the instance) in the instances that share the same value. Is that right? $\endgroup$
    – r_31415
    Jan 19, 2013 at 21:37
  • $\begingroup$ @RobertSmith: That's right. $\endgroup$ Jan 19, 2013 at 21:39
  • $\begingroup$ Great. Last question: What kind of split is performed with those binary attributes? $\endgroup$
    – r_31415
    Jan 19, 2013 at 21:45
  • $\begingroup$ @RobertSmith: According to your quote, they are split the same way that numeric attributes are split. That is, they're converted into decimal: 11, 01, 00 are treated the same way you'd treat 3, 1, 0. 10 variables would become 511, 255, 127, 63, 31, 15, 7, 3, 1, 0. $\endgroup$ Jan 19, 2013 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.