Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

How to connect Process and Operator?

prayerslayerprayerslayer Member Posts: 3 Contributor I
edited November 2018 in Help
Hello!

I'm very aware of the fact that it's not being welcomed to ask questions regarding the chaining of operators programatically. However, I need to do this for my thesis and hope that you'll kindly oversee it this time.

Everything works really well already, but I couldn't figure out how to connect the output of an operator to a result port of my process. Could anyone give me a hint? It's this part:

image

I tried to look for ports of the RootOperator, but there was no output:

System.out.println("looking for process ports");
for (String port : process.getRootOperator().getInputPorts().getPortNames())
System.out.println(port);
Am I able to add it anyway? Or somewhere else?

The actual problem I have is that after the process finished, I can't access the result (because there is none, I guess).
INFO: Process finished successfully after 3 s
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:570)
at java.util.ArrayList.get(ArrayList.java:348)
at com.rapidminer.operator.IOContainer.getElementAt(IOContainer.java:112)
at BackendTest.main(BackendTest.java:128)
At this line:
if (process_result.getElementAt(0) instanceof ExampleSet) { ... }
Thanks in advance!
Tagged:

Answers

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

    you may ask whatever you want to know - we just encourage others to use the GUI approach because it is much easier. However if there's a reason why you need to do it programatically, it is perfectly fine ;)

    I put together a quick example for you:

    This is the example process with an operator not connected to an output port.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.003">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.003" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <parameter key="parallelize_main_process" value="false"/>
        <process expanded="true" height="639" width="950">
          <operator activated="true" class="retrieve" compatibility="5.2.003" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
    </process>
    This line connects the operator referenced by its name to the first output port of the process:

    process.getOperator("Retrieve").getOutputPorts().getPortByName("output").connectTo(process.getRootOperator().getSubprocess(0).getInnerSinks().getPortByIndex(0));
    And in case you need a procedure for input ports as well, you can find it here.

    Regards,
    Marco
  • prayerslayerprayerslayer Member Posts: 3 Contributor I
    Thanks a lot, works like a charm :)
Sign In or Register to comment.