[SOLVED]operator.setParameter method

AleAle Member Posts: 6 Contributor II
edited November 2018 in Help
Hi, I'm new to rapidminer. I'm trying to execute this simple process using java code
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.013">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.013" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="retrieve" compatibility="5.3.013" expanded="true" height="60" name="Retrieve model" width="90" x="45" y="75">
       <parameter key="repository_entry" value="//Local Repository/data/model"/>
     </operator>
     <operator activated="true" class="retrieve" compatibility="5.3.013" expanded="true" height="60" name="Retrieve testing" width="90" x="45" y="210">
       <parameter key="repository_entry" value="//Local Repository/data/testing"/>
     </operator>
     <operator activated="true" class="apply_model" compatibility="5.3.013" expanded="true" height="76" name="Apply Model" width="90" x="313" y="75">
       <list key="application_parameters"/>
     </operator>
     <connect from_op="Retrieve model" from_port="output" to_op="Apply Model" to_port="model"/>
     <connect from_op="Retrieve testing" from_port="output" to_op="Apply Model" to_port="unlabelled data"/>
     <connect from_op="Apply Model" from_port="labelled data" to_port="result 1"/>
     <portSpacing port="source_input 1" spacing="0"/>
     <portSpacing port="sink_result 1" spacing="0"/>
     <portSpacing port="sink_result 2" spacing="0"/>
   </process>
 </operator>
</process>
I need to change the repository_entry value of the two retrieve operators. I'm using the setParameter method
Operator opRetModel = process.getOperator("Retrieve model");
           opRetModel.setParameter(???,model path)
but I don't understand what to use as first parameter to specify the path of the saved model.

I've read the question n 6 at this page http://rapid-i.com/rapidforum/index.php/topic,5807.0.html but I don't understand what is that class SingleDocumentInputOperator.
Thanks for your help.
Tagged:

Answers

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

    I have updated the question in the FAQ because the operator used was from an extension and thus not the best example.
    I'll rewrite this here anyway:

    Step 1) Open the "OperatorsCore.xml" file and search for the name of the operator. In your case, <key>retrieve</key> is the one you're looking for. Note how that key is the same as the 'class' attribute in the process XML. Now you know that "<class>com.rapidminer.operator.io.RepositorySource</class>" is the implementation class of the operator.
    Step 2) You can then check said class for string constants and you will find "PARAMETER_REPOSITORY_ENTRY". This is the key you need to use.

    Regards,
    Marco
  • AleAle Member Posts: 6 Contributor II
    Thank you very much, now I understand how it works.
    I'm still having problems calling this method when the parameter to set is the path to a file.
    This code

    Operator opReadModel = process.getOperator("Read model");
    String path="/home/alessia/Scrivania/model.mod";
    opReadModel.setParameter(com.rapidminer.operator.io.ModelLoader.PARAMETER_MODEL_FILE,path);
    gives me a null pointer exception on the third row even if the path is correct and the file exists. If I execute the process through rapidminer gui with the same parameter it works  ???
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    in the 3rd row of your code the only possiblity for a NullPointerException is when "opReadModel" is null. This is also quite likely given your process xml: The operator is called "Retrieve model" in your process, not "Read model". The call "process.getOperator("name") returns null if no operator is found with the given name.

    Regards,
    Marco
  • AleAle Member Posts: 6 Contributor II
    You were right, the operator object was null.
    Thank you very much.  ;D
Sign In or Register to comment.