The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Add label to existing ExampleSet
Hi,
I have an existing example set. How can I effectively add a label attribute to the existing example set?
radone
I have an existing example set. How can I effectively add a label attribute to the existing example set?
throws java.lang.ArrayIndexOutOfBoundsException: -1 on the last line.
ExampleSet newExampleSet = .... (an existing example set);
// ADD LABEL ATTRIBUTE
Attribute label = AttributeFactory.createAttribute("label", Ontology.NOMINAL);
newExampleSet.getAttributes().setLabel(label);
// SET NOMINAL VALUE
Example e = newExampleSet.getExample(0);
e.setLabel(label.getMapping().mapString(clsName));
Thanks in advance for any help,
SEVERE: Process failed: operator cannot be executed (-1). Check the log messages...
java.lang.ArrayIndexOutOfBoundsException: -1
at com.rapidminer.example.table.DoubleArrayDataRow.set(DoubleArrayDataRow.java:52)
at com.rapidminer.example.table.AbstractAttribute.setValue(AbstractAttribute.java:184)
at com.rapidminer.example.table.DataRow.set(DataRow.java:85)
at com.rapidminer.example.Example.setValue(Example.java:140)
at com.rapidminer.example.Example.setLabel(Example.java:178)
at ... last code of the example above ...
radone
Tagged:
0
Answers
this should work: There are other ways, but this one should work just fine.
Regards,
Marco
Unfortunately, ended with exactly the same error. I got some debugging info about the just inserted label and it seems that "-1" in my outpput might have something to do with my problem? the system out gives: and the code: throws:
I forgot a line in my first reply, so I had to edit it. If you copy that codeblock, you should be fine.
Note that to be able to use the label attribute must already be present in the attribute set.
Regards,
Marco
The line: was exactly what I was missing.