Creating a string attribute in weka java API

so I'm trying to create a new Attribute line using weka java API ...

looking through the javadocs API, it seems like a way to do this is to use this constructor:

Attribute

public Attribute(java.lang.String attributeName,
                 FastVector attributeValues)

    Constructor for nominal attributes and string attributes. If a null vector of attribute values is passed to the method, the attribute is assumed to be a string.

    Parameters:
        attributeName - the name for the attribute
        attributeValues - a vector of strings denoting the attribute values. Null if the attribute is a string attribute.

but I am fixated on what I need to pass to attributeValues โ€‹โ€‹...

when I put zero, Java complains about protected objects
when I put Null, this is a syntax error
when I insert new FastVector(), it becomes a nominal attribute, which is empty and not a string attribute ...
when I create a new object:

FastVector fv = new FastVector();
fv.addElement(null);

and then pass fv to the argument, it returns a null pointer exception ...

what exactly should be placed in the attributeValues โ€‹โ€‹argument so that it becomes a string attribute?

+5
2

null FastVector. :

    FastVector attributes = new FastVector();
    attributes.addElement(new Attribute("attr", (FastVector) null));

: http://weka.wikispaces.com/Creating+an+ARFF+file

+8

STRING WEKA :

 new Attribute("Distribution_weight",(FastVector) null);

- NULL WEKA NULL Java weka.jar throw exceptions.

+3

All Articles