🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Transforming ExampleSet into 2D double Array

User: "milkov"
New Altair Community Member
Updated by Jocelyn
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

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Marco_Boeck"
    New Altair Community Member
    Hi,

    one possible way:

    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++;
    }
    Regards,
    Marco