Skip to content

Rename attribute values

After discretizing an attribute you might want to rename the values of the newly created nominal attribute. E.g., after discretizing a numeric attribute with values ranging from 1 to 100 you might end up with a nominal attribute that has the following values:

 '1-15','16-18','29-100'
You can use the renameAttributeValue(...) method of the weka.core.Instances class (see API) to rename this values into, e.g., 0, 1 and 2. Here's a code snippet how to do this (arff is an Instances object, att is an attribute of the same instances object):

 for (int n = 0; n < att.numValues(); n++) {
    arff.renameAttributeValue(att, att.value(n), "" + n);
The Rename.java like mentioned above.

See also#

Downloads#