Options

"Running an xml process file with the API"

emolanoemolano Member Posts: 13 Contributor II
edited May 2019 in Help
Hi there,
I have an xml process file. It runs fine with the rapidminer GUI. Is it possible to run it from a java application using the API?
I know one could be rewrite the process using the API
something like  inputOperator = OperatorService.createOperator("DatabaseExampleSource");
      // set parameters
      inputOperator.setParameter("database_system", "MySQL"); ...

but I just want to run my existing xml process file within an eclipse project.

Thanks. Help is appreciated.

Answers

  • Options
    steffensteffen Member Posts: 347 Maven
    Hello emolano

    I assume you have read chapter 7 of the tutorial.pdf.

    The requested can be perform like this:

    File processFile = new File("d:/test.xml");
    if (!processFile.exists()){throw new Exception("File '" + processFile.getAbsolutePath()+ "' does not exist!");}
    Process process = RapidMiner.readProcessFile(processFile);
    IOContainer input = new IOContainer();
    IOContainer output = process.run(input);
    hope this was helpful

    regards,

    Steffen
  • Options
    emolanoemolano Member Posts: 13 Contributor II
    Thanks. It woks fine.
    Here my code with the init part:


    import java.io.File;
    import com.rapidminer.Process;
    import com.rapidminer.RapidMiner;
    import com.rapidminer.operator.*;


    public class executeXMLModel {

      public static void main(String[] argv) throws Exception {
     
      String modelFile="C:/Documents and Settings/emolano/My Documents/rm_workspace/mining/platform/xmlModel.xml";

      // set properties to point to plugin directory
          String pluginDirString = new File("C:\\Program_Files\\Rapid-I\\RapidMiner\\lib\\plugins").getAbsolutePath();
          System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
          // set properties - rapid miner home
          String path="C:\\Program Files\\Rapid-I\\RapidMiner\\";
      System.setProperty("rapidminer.home",path );
     
          // initialization
      RapidMiner.init(false, true, true, true);
     
      File processFile = new File(modelFile);
      if (!processFile.exists()){throw new Exception("File '" + processFile.getAbsolutePath()+ "' does not exist!");}
      Process process = RapidMiner.readProcessFile(processFile);
      IOContainer input = new IOContainer();
      IOContainer output = process.run(input);
           
      }
    }
Sign In or Register to comment.