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
Creating new attributes / Custom Example Set
Hi!
I'm currently writing my own bunch of operators. One task would be to create a new attribute. I tried to copy this process from AttributeConstruction / ExpressionParser. Anyhow it doesn't work. When running my operator in RapidMiner I get the error "ArrayIndexOutOfBoundsException occured in 1st application of Add Point Mapping (Add Point Mapping)".
I'm using this code (minimal example):
[Edit:] As workaround I gave AttributeConstruction. I came up with the same error. So the problem seems to be in my Custom ExampleSet. But I haven't overridden anything there. *confused*.
I've written an Reader that creates my PointExampleSet from file(s). Therefore I'm using a MemoryExampleTable.
Best regards,
Michael
I'm currently writing my own bunch of operators. One task would be to create a new attribute. I tried to copy this process from AttributeConstruction / ExpressionParser. Anyhow it doesn't work. When running my operator in RapidMiner I get the error "ArrayIndexOutOfBoundsException occured in 1st application of Add Point Mapping (Add Point Mapping)".
I'm using this code (minimal example):
public IOObject[] apply() throws OperatorException {For my project I had to extend ExampleSet, but I didn't override any method. What am I doing wrong?
PointExampleSet exampleSet = getInput(PointExampleSet.class);
Attribute xAttr = AttributeFactory.createAttribute("x1", Ontology.REAL);
exampleSet.getExampleTable().addAttribute(xAttr);
exampleSet.getAttributes().addRegular(xAttr);
for (Example example : exampleSet) {
example.setValue(xAttr, 0);
}
return new IOObject[]{exampleSet};
}
[Edit:] As workaround I gave AttributeConstruction. I came up with the same error. So the problem seems to be in my Custom ExampleSet. But I haven't overridden anything there. *confused*.
I've written an Reader that creates my PointExampleSet from file(s). Therefore I'm using a MemoryExampleTable.
Best regards,
Michael
Tagged:
0
Answers
did you add the data via the addDataRow methods in [tt]MemoryExampleTable[/tt]. If you just create an example set from a newly created [tt]MemoryExampleTable[/tt], there won't be any data. So, the common way to create an example set is to create a [tt]MemoryExampleTable[/tt], add the data using the addDataRow methods and then create the example set afterwards ...
Kind regards,
Tobias
I have done it this way. I've used the following code (excerpt):
I get the ArrayIndexOutOfBounds Exception when I'm trying to access xAttr, or yAttr in an Example.
As base for the ExampleTable I've used DoubleArrayDataRow with an simple double array as constructor argument. Might there be the problem? If yes, what else should I use?
Greetings,
Michael
I think you have somehow rotated your data. In our terminology each point will be one example and hence one data row. So I think your data row should have 2 dimensions (x and y attributes) plus a number for special attributes like label etc.
An easy way for getting the correct number of attribute's is as follows:
1. Create your Attributes using the AttributeFactory
2. Add all these attributes into the ExampleTable
3. Create data rows using a DataRowFactory with exampleTable.getAttributeCount as length
4. Set the values in the datarow using dataRow.setValue(attribute, value) for each attribute you created
This should work,
Greetings,
Sebastian
For example I want to calculate the center ("Am") of two points ("A1" and "A2"). Therefore I have to add two new attribute to an example/point (say "Am_x" and "Am_y") and add a mapping in my example set ("Am" --> "Am_x", "Am_y"). With the first part I have trouble. This sounds good. But to keep my approach flexible, I don't know a priori how many attributes I will need. As I don't know how many points are stored in each file. But maybe I find a way to use this.
Best regards,
Michael
It works now. Thanks a lot, Sebastian. Your were (nearly) right. I have to use the base table instead of the example set. But not only for creating the example set but also for adding the attributes.
Thank you all a lot for your help!
Michi