Invoking RapidMiner using a method call on a Java class on a Tomcat server

Rick4031Rick4031 Member Posts: 3 Contributor I
edited November 2018 in Help
I am new to RapidMiner so I apologize upfront for my inexperience. I have written a web application in Flex/ActionScript that learners and educators can use to create a case formulation based on a given scenario. Their formulations are indented outlines of text that integrate knowledge with the particular observations in the scenario. I have used RapidMiner GUI to compare the two documents for similarity by entering each directly into its own create document operator which then serve as inputs to a single Process Documents operator, which is then connected to a Data to Similarity operator and this works fine.

I want to do the same using a remote method call to a java class on a Tomcat server and I cannot for the life of me (actually only 3 straight days) figure out how to set this up.

Flex applications can make a remote call with parameters to a java class on the Tomcat server and invoke a method in that class. I am trying configure this method so it will receive two large strings, the learner’s formulation and the educator’s formulation which I have shortened below to save space, and then run RapidMiner using the DocumentCompare.rmp listed below. When completed I need it to return an object back to Flex that contains the result. I need help with setting up the method and knowing where on the Tomcat server that I should put the DocumentCompare.rmp file so RapidMiner can find it. Thank you in advance for any help that you can offer.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.008">
  <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
    <process expanded="true" height="581" width="872">
      <operator activated="true" class="text:create_document" compatibility="5.2.004" expanded="true" height="60" name="Create Document" width="90" x="112" y="75">
        <parameter key="text" value="Rochelle (used with permission from Dr. Tracy Eells)  &#10;Problem List  &#10;    Patient-related factors  &#10;          depression  &#10;          anxiety  &#10;          mood instability  &#10;          poor anger management  &#10;          poor sleep  &#10;          headaches  &#10;          social isolation  &#10;"/>
        <parameter key="add label" value="true"/>
        <parameter key="label_value" value="ReferenceFormulation"/>
      <operator activated="true" class="text:create_document" compatibility="5.2.004" expanded="true" height="60" name="Create Document (2)" width="90" x="101" y="301">
        <parameter key="text" value="Rochelle (used with permission from Dr. Tracy Eells)  &#10;Problem List  &#10;    Patient-related factors  &#10;          depression  &#10;          anxiety  &#10;          mood instability  &#10;          poor anger management  &#10;          poor sleep  &#10;          headaches  &#10;          social isolation  &#10;          possible limited motivation or ability to come to treatment  &#10;          dependency  &#10;          mood problems exacerbated by uncontrolled diabetes  &#10;    Environment-related factors  &#10;          financial strain  &#10;          possible impending housing problem  &#10;          possible infidelity  &#10;          chemically dependent husband  &#10;    Temporal dimension  &#10;          Distal  &#10;              grief due to death of son  &#10;              grief due to past rape  &#10;              history of suicidal ideation and threatened attempts  &#10;          Proximal  &#10;              possible infidelity  &#10;Diagnosis (provisional)  &#10;    Axis I  &#10;          (296.90) Mood disorder not otherwise specified  &#10;              &#10;"/>
        <parameter key="add label" value="true"/>
        <parameter key="label_value" value="SubmittedFormulation"/>
      <operator activated="true" class="text:process_documents" compatibility="5.2.004" expanded="true" height="112" name="Process Documents" width="90" x="313" y="165">
        <parameter key="vector_creation" value="Term Occurrences"/>
        <parameter key="prune_below_absolute" value="2"/>
        <parameter key="prune_above_absolute" value="99"/>
        <process expanded="true" height="599" width="891">
          <operator activated="true" class="text:tokenize" compatibility="5.2.004" expanded="true" height="60" name="Tokenize" width="90" x="179" y="30"/>
          <operator activated="true" class="text:transform_cases" compatibility="5.2.004" expanded="true" height="60" name="Transform Cases" width="90" x="315" y="28"/>
          <operator activated="true" class="text:filter_stopwords_english" compatibility="5.2.004" expanded="true" height="60" name="Filter Stopwords (English)" width="90" x="442" y="26"/>
          <operator activated="true" class="text:filter_by_length" compatibility="5.2.004" expanded="true" height="60" name="Filter Tokens (by Length)" width="90" x="600" y="26">
            <parameter key="min_chars" value="2"/>
            <parameter key="max_chars" value="99"/>
          <connect from_port="document" to_op="Tokenize" to_port="document"/>
          <connect from_op="Tokenize" from_port="document" to_op="Transform Cases" to_port="document"/>
          <connect from_op="Transform Cases" from_port="document" to_op="Filter Stopwords (English)" to_port="document"/>
          <connect from_op="Filter Stopwords (English)" from_port="document" to_op="Filter Tokens (by Length)" to_port="document"/>
          <connect from_op="Filter Tokens (by Length)" from_port="document" to_port="document 1"/>
          <portSpacing port="source_document" spacing="0"/>
          <portSpacing port="sink_document 1" spacing="0"/>
          <portSpacing port="sink_document 2" spacing="0"/>
      <operator activated="true" class="data_to_similarity" compatibility="5.2.008" expanded="true" height="76" name="Data to Similarity" width="90" x="514" y="165">
        <parameter key="measure_types" value="NumericalMeasures"/>
        <parameter key="numerical_measure" value="CosineSimilarity"/>
      <connect from_op="Create Document" from_port="output" to_op="Process Documents" to_port="documents 1"/>
      <connect from_op="Create Document (2)" from_port="output" to_op="Process Documents" to_port="documents 2"/>
      <connect from_op="Process Documents" from_port="example set" to_op="Data to Similarity" to_port="example set"/>
      <connect from_op="Data to Similarity" from_port="similarity" 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"/>
[ /code]


  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn

    it is certainly possible to implement it somehow on your own, but I would strongly suggest to have a look at our RapidAnalytics server. It is capable of providing access to RapidMiner processes as a webservice, which is exactly what you want to do, if I understand you correctly.

    Happy Mining!
  • Rick4031Rick4031 Member Posts: 3 Contributor I
    Thank you for getting back to me. I looked into RapidAnalytics as you suggested, but it appears that it is still the user interacting directly with the GUI interface on the server.

    I want to have a Flex/ActionScript program make a remote method call to a Java class on a server that starts RapidMiner without a gui, runs the rmp file by substituting the two string variables that are arguments in the call, and then returns the result back to the calling program. The user of the Flex/ActionScript front-end should have no clue that RapidMIner exists. The user just has an application with two strings and a button that says, "Compare". They click it, and the call is made to the server and the result is returned to the application which displays the result in a window. The rmp file is in my previous post.

    I have stumbled around with the following Java class and rapidMinerCompare method, but I could be way off track. I think the resultExample is running, though I don't know how get at the results to return them back to the Flex/ActionScript program that made the remote method call. Returning "finished" is temporary to let me know that the method ran. The goal is to return the results of the run.

    An example of how the call does work is if I call the sayHello(String name) method with sayHello("Rick"), the string that is returned to the program is "Hello Rick!"

    Is what I am trying to do even possible on a Tomcat server?
    Thank you again,
    public class RapidMinerService {

    public String sayHello(String name) {
    return "Hello " + name + "!";

    public String rapidMinerCompare(String submittedFormulation,String referenceFormulation) throws RepositoryException, OperatorException {

    try {

    // print submitted
    System.out.println("Submitted: " + submittedFormulation);
    System.out.println("Reference: " + referenceFormulation);
    // set amount of log messages - not sure about the effect

    // initialize - possible to switch off certain resources?

    // class running process gets process as XML file
    Process process = new Process(new File("C:/Documents and Settings/Rick/My Documents/RapidMiner/Project/Compare Formulations/formulationCompare.rmp"));
    IOContainer resultExample =;
    System.out.println("am here");

    } catch (IOException e) {
    System.out.println("Error: " + e);
    // } catch (OperatorException e) {
    // System.out.println("Error: " + e);
    } catch (XMLException e) {
    System.out.println("Error: " + e);
    return "finished";

  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    As I said, you can send http requests to the RapidAnalytics server from the script, and the server will send a reply back to you without any gui interaction. Of course, the configuration of the webservice is done via the web gui, but this in done only once by the administrator (that is you), afterwards you don't need to open the web gui anymore.

    If this is not sufficient, please leave me a small note here. However I think anything else would be a bit like reinventing the wheel.

    Best, Marius
  • Rick4031Rick4031 Member Posts: 3 Contributor I
    For some reason I thought RapidAnalytics was a service that I would subscribe to at Rapid-I and not something I could install and use on my own with the correct licensing. Noob is as noob does.<g> For now I am running on the backs of a different set of alligators, so it will be a while before I can test it and post my results. Thank you for your patience.
  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    Well, talking about licensing, please keep in mind that the community edition of RapidAnalytics is licensed under the AGPL. That means that also your application has to be released under that license if it accesses RapidAnalytics via webservice (or any other means). But that would also be the case if you used the RapidMiner community edition.

    Best, Marius
Sign In or Register to comment.