Transforming ExampleSet into 2D double Array
milkov
New Altair Community Member
Hello,
I have a question that you will not probably like to hear, but it would really help me with my work. I'm transforming a feature selection method into a RapidMiner operator and right now I have about 3,5k lines of code. The problem is, that this method expects a 2D double array input.
My question is - is there an easy way to transform ExampleSet into 2D double array and vica versa?
Thank you for your help,
Milan
I have a question that you will not probably like to hear, but it would really help me with my work. I'm transforming a feature selection method into a RapidMiner operator and right now I have about 3,5k lines of code. The problem is, that this method expects a 2D double array input.
My question is - is there an easy way to transform ExampleSet into 2D double array and vica versa?
Thank you for your help,
Milan
0
Answers
-
Hi,
one possible way:
Regards,
ExampleSet resultSet = (ExampleSet) result.getElementAt(0);
Attributes attributes = resultSet.getAttributes();
Iterator<Attribute> attrIterator = attributes.allAttributes();
double[][] array2D = new double[attributes.allSize()][resultSet.getExampleTable().size()];
int attrIndex = 0;
int exaIndex = 0;
while (attrIterator.hasNext()) {
Attribute att = attrIterator.next();
ExampleReader exampleReader = new SimpleExampleReader(resultSet.getExampleTable().getDataRowReader(), resultSet);
exaIndex = 0;
while (exampleReader.hasNext()) {
array2D[attrIndex][exaIndex] = exampleReader.next().getValue(att);
exaIndex++;
}
attrIndex++;
}
Marco0