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

How to load String Array to RM? Java

kemockemoc Member Posts: 8 Contributor II
edited November 2018 in Help
Hi,
I don't know how to load string vales to RM?
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    please be more specific. I have absolutely no clue what you want to achieve.
    But for starters, I'll just post a link that might be interesting to you ;)

    Click here.

    Regards,
    Marco
  • kemockemoc Member Posts: 8 Contributor II
    Marco Boeck wrote:

    Hi,

    please be more specific. I have absolutely no clue what you want to achieve.
    But for starters, I'll just post a link that might be interesting to you ;)
    ...
    Regards,
    Marco
    I would load to the RM data with String values from Java file, for example from Map<Integer, ArrayList<String>>, it represent a table.
    com.rapidminer.example.set.* - accept only numeric values.
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    please consider loading the data via one of the RM operators in a process you designed. If for some reason that is not feasible, and you really need to do it programmatically, you could try using something along these lines:

    MemoryExampleTable table = new MemoryExampleTable(copiedListOfAttributes);
    double[] doubleArray = null;
    [...]
    for (int j=0; j<copiedListOfAttributes.size(); j++) {
    Attribute a = copiedListOfAttributes.get(j);
    value = rowList.get(j);
    // if numerical attribute
    if (a.isNumerical()) {
    // put it into the array
    if (value == null) {
    doubleArray = Double.NaN;
    } else {
    doubleArray = Double.parseDouble(value);
    }
    // non-numerical attribute
    } else {
    // special case: date attribute
    if (Ontology.ATTRIBUTE_VALUE_TYPE.isA(a.getValueType(), Ontology.DATE ) ||
    Ontology.ATTRIBUTE_VALUE_TYPE.isA(a.getValueType(), Ontology.DATE_TIME) ||
    Ontology.ATTRIBUTE_VALUE_TYPE.isA(a.getValueType(), Ontology.TIME)) {
    if (value == null) {
    doubleArray = Double.NaN;
    } else {
    doubleArray = Double.parseDouble(value);
    }
    } else {
    // create a new mapping (cleared earlier) if needed, add resulting index to array
    if (value == null) {
    doubleArray = Double.NaN;
    } else {
    doubleArray = a.getMapping().mapString(rowList.get(j));
    }
    }
    }
    }
    [...]
    // add the double array for each row to the ExampleSet
    table.addDataRow(new DoubleArrayDataRow(doubleArray));
    // create example set
    ExampleSet exSet = table.createExampleSet();
    Regards,
    Marco
Sign In or Register to comment.