"Problems implementing RM5 in Java Application"

biti
biti New Altair Community Member
edited November 5 in Community Q&A
Hi there,

I just wrote a small application, that uses RM4.x. It generates it's own process how it is described in the old RM Tutorial (Chapter 7/ Figure 7.3).
It generates the Operators applys a model to the testdata and generates output.
Now I wanted the application to use RM5, without using now deprecated methods.
The approach of using input and output-ports looks good to me, but now I have several problems...
So I tried a very simple application to review the changes I have to make.

I generated Operators like before, connected output- to inputports. But when I want to run the Model Applier I get the following Exception.

com.rapidminer.operator.UserError: No data was deliverd at port Apply Model.unlabelled data.
at com.rapidminer.operator.ports.impl.AbstractPort.getData(AbstractPort.java:78)
at com.rapidminer.operator.ModelApplier.doWork(ModelApplier.java:81)
at ProcessGenerator.main(ProcessGenerator.java:74)
When I debug, the output ports of the ModelLoader and the ExampleSource are connected to the corresponding inputports.
Whilst there is no other documentation or tutorial for RM5, this seems the only way to get help for me.

Thanks

Markus

Answers

  • land
    land New Altair Community Member
    Hi Markus,
    this is the correct place, don't worry about this. As long as we didn't manage to publish a new tutorial, nobody can blame you for asking questions you could answer yourself after rtfm. :)
    So, although you did not include the complete code, I guess, you did not connect the operator receiving input from your code to the ports of the process root operator. As you see in the gui, each process has some input and output ports. Although not many people already get used to the input ports and use only output ports, because this feels more natural.
    There are two ways of handling things: You could either deliver the data to each single input port of each operator manually and fetch the output afterwards. This gives you the most control and the most work.
    I would recommend to build or load a process, and either address it's input ports yourself or use the run(IOContainer) method to deliver data to the input ports. The first object in the iOContainer will be assigned to the first input of the process.

    A small sample that will execute a preloaded process with several input objects:
    // construct example set
    Attribute ageAttribute = AttributeFactory.createAttribute("customer_age", Ontology.POLYNOMINAL);
    Attribute typeAttribute = AttributeFactory.createAttribute("customer_type", Ontology.POLYNOMINAL);
    Attribute groupAttribute = AttributeFactory.createAttribute("customer_group", Ontology.POLYNOMINAL);
    Attribute textAttribute = AttributeFactory.createAttribute("text", Ontology.STRING);

    MemoryExampleTable table = new MemoryExampleTable(ageAttribute, typeAttribute, groupAttribute, textAttribute);

    // adding row
    DataRow row = ROW_FACTORY.create(4);
    row.set(ageAttribute, ageAttribute.getMapping().mapString(metaData.age));
    row.set(typeAttribute, typeAttribute.getMapping().mapString(metaData.type));
    row.set(groupAttribute, groupAttribute.getMapping().mapString(metaData.group));
    row.set(textAttribute, textAttribute.getMapping().mapString(text));
    table.addDataRow(row);

    ExampleSet exampleSet = table.createExampleSet();

    // start the process with the exampleSet, preprocessingModel, ClassificationModel and WordList
    // in an IOContainer, to lay it on the ports of the process

    IOContainer context;
    context = new IOContainer(exampleSet, preprocessingModel_de, wordList_de, classificationModel_de);

    IOContainer result = sentimentProcess.run(context);
    ExampleSet resultSet = result.get(ExampleSet.class);
    Attribute confidence = resultSet.getAttributes().getSpecial("confidence_reasons_positive");
    double confidencePositive = 0;
    for (Example example : resultSet) {
    confidencePositive = example.getValue(confidence);
    }
    return confidencePositive;
    Greetings,
      Sebastian
  • biti
    biti New Altair Community Member
    Hi Sebastian,

    I tried to follow your example.

    So I assume, you loaded a complete process from an XML file.
    This process already includes the operators and connections.
    The inputports of the operators are connected to the input of the process itself (for the operators getting information from 'outside' by the context object)
    The order of the inputports used in the process is deciding the the order for the IOObjects in the context object.

    Right so far?

    I made a very simple example for me (only one operator, just for testing). This works, but before trying more compelex processes, I want my assumptions confirmed ;)


    Thank you so far for your help!

    Greetings,

    Markus
  • land
    land New Altair Community Member
    Hi,
    I think this is correct so far. You might proceed :)

    Greetings,
      Sebastian