"implementing rapidminer in java application"

tapankhistetapankhiste Member Posts: 4 Contributor I
edited June 2019 in Help
how we run that process from netbeans ?
in netbeans i run code to creating a proccesse and its run successfully but no output result show in netbeans

i run following code in netbeans :::


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package processcreator;
import com.rapidminer.tools.OperatorService;
import com.rapidminer.RapidMiner;
import com.rapidminer.Process;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.IOObject;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.operator.generator.ExampleSetGenerator;
import java.io.IOException;

public class ProcessCreator {
   private static IOObject myExampleSet;

   
   public static Process createProcess() {

       // invoke init before using the OperatorService
   RapidMiner.init();


// create process
Process process = new Process();
try {
   // create operator
   Operator inputOperator =
       OperatorService.createOperator(ExampleSetGenerator.class);
       
   // set parameters
   inputOperator.setParameter("target_function", "sum classification");
   
   // add operator to process
   process.getRootOperator().addOperator(inputOperator);

   // add other operators and set parameters
   // [...]
} catch (Exception e) { e.printStackTrace(); }
return process;
   }

   public static void main(String[] argv) {
// create process
Process process = createProcess();
// print process setup
System.out.println(process.getRootOperator().createProcessTree(0));

try {
   // perform process
   process.run();
           
       
                   
                   
           
   // to run the process with input created by your application use
       // process.run(new IOContainer(new IOObject[] { ... your objects ... });
} catch (OperatorException e) { e.printStackTrace(); }
   }
}

please give the solution that how i run rapid miner process in java application
Tagged:

Answers

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

    please read our development FAQ: http://rapid-i.com/rapidforum/index.php/topic,5807.0.html

    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Sir Macro,

    I am using eclipse to run the process of rapidminer from java in eclipse. The process runs, but i am not getting the output. Can you please help me to get the result as displayed in rapidminer. I have seen your previous answer, but from that i am not getting output. Please help me. :'(
    It is needed for my Dissertation

    This is the code I am using:

    package rapid_process;

    import com.rapidminer.Process;
    import com.rapidminer.RapidMiner;
    import com.rapidminer.RepositoryProcessLocation;
    import com.rapidminer.operator.Operator;
    import com.rapidminer.operator.OperatorException;
    import com.rapidminer.operator.io.ExcelExampleSource;
    import com.rapidminer.repository.RepositoryLocation;
    import com.rapidminer.tools.XMLException;

    import java.io.File;
    import java.io.IOException;
    import java.lang.Object;
    import java.io.File;

    import com.rapidminer.RapidMiner.ExecutionMode;
    import com.rapidminer.example.Attributes;
    import com.rapidminer.example.Example;
    import com.rapidminer.example.ExampleSet;
    import com.rapidminer.example.set.SimpleExampleSet;
    import com.rapidminer.operator.IOContainer;
    import com.rapidminer.operator.IOObject;
    import com.rapidminer.repository.IOObjectEntry;
    import com.rapidminer.operator.ModelApplier;
    import com.rapidminer.operator.Operator;
    import com.rapidminer.operator.io.ModelLoader;
    import com.rapidminer.tools.OperatorService;

    public class process {

    public static void main(String[] args) throws Exception {
    // Path to process-definition
    final String processPath = "/C:/Users/LENOVO/.RapidMiner5/repositories/Local Repository/star.rmp";

    // Init RapidMiner
    RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
    RapidMiner.init();

    // Load process
    final com.rapidminer.Process process = new com.rapidminer.Process(new File(processPath));
    process.run();

    }


    }



    Output:

    INFO: Process C:\Users\LENOVO\.RapidMiner5\repositories\Local Repository\star.rmp starts
    Apr 10, 2015 2:56:04 PM com.rapidminer.Process run
    INFO: Process C:\Users\LENOVO\.RapidMiner5\repositories\Local Repository\star.rmp finished successfully after 0 s


    But I want result output to be displayed
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    well, you're executing the process, but you're simply ignoring the return value ;)
    Question 5 of the FAQ has an example:

    IOContainer ioResult = myProcess.run(ioInput);

    // use the result(s) as needed, for example if your process just returns one ExampleSet, use this:
    if (ioResult.getElementAt(0) instanceof ExampleSet) {
        ExampleSet resultSet = (ExampleSet)ioResult.getElementAt(0);
    }
    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Macro Sir,

    What does ioInout stands for here? Tell me about the declaration of  ioInput..
    And if there are more than one ExampleSet then?

    Will it display the output (like accuracy is displayed in the rapidminer along with the confusion matrix) ? or wordlist that is displayed will be the output?
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    which version are we talking about? 5.3? If so, you will have the sources checked out. Then you can investigate what everything is by looking at the code and the (sadly rare) JavaDoc of the classes.
    If we're talking version 6, the only thing I can offer at the moment is to also download the 5.3 sources and look at them. The very core calls like process.run() and its return values have not changed between 5 and 6.
    The input is optional and of the type IOContainer. This is a container for any IOObjects. IOObject is the top-level interface every data object of RapidMiner Studio must implement. They are delivered to the process input ports (left side ports in your process). You don't need to pass them if you don't use them. Outputs work the same. Ports on the right side of the process.
    The type of the returned objects depends on what your process returns. An ExampleSet is different from a Model from a Document etc. Use breakpoints to determine what you get.

    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Thank You so much Macro Sir for you quick reply.

    I am using 5.3 version. I understod about the ioInput.

    I ran the code but not displaying output. Is it due that my output is accuracy with confusion matrxi and model
    If i want to display the output using java code with confusion matrix and model or anyone of them. Then what should I do?

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

    well, look at the objects you're getting as output. Inspect their implementation code and see what methods they offer. Use them to extract the information you require. Explore what is available, maybe check out how RapidMiner Studio uses the data. Everything you need to know is contained in the sourcecode ;)

    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Ohk. Thank you.

    Can you tell me the source code ??
  • JollyJolly Member Posts: 11 Contributor II
    Macro Sir,

                I got that Modelloader is required to load the model(ans is as model as output with confusion matrix in rapidminer). want to load using the java in eclipse.
    help me.
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    have a look at the package "com.rapidminer.gui.viewer". There are various GUI classes which display different IOObjects in RapidMiner Studio. For example, a ConfusionMatrixViewer is in there. Have a look at where the constructors are called for these GUI objects, then you will find the actual IOObject implementations. Then you can cast your IOObject results of your process to the appropriate classes and work with them. By looking at the GUI classes you can get a first impression of what information you can display.
    That's the advice I can give you, I do not have the time to build custom code as per your request.

    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Thank you Sir.

    Sir I want to classify the emoticons with the sentences (sentiment analysis) that has opinions about a particular product. Can you please tell me the rapidminer code?
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    text analysis sources can be found here: https://svn.code.sf.net/p/rapidminer/code/Plugins/TextProcessing/Unuk/
    If you require help building your actual RapidMiner Studio process in the GUI, please ask your question here: http://rapid-i.com/rapidforum/index.php/board,5.0.html

    Regards,
    Marco
  • JollyJolly Member Posts: 11 Contributor II
    Hello Macro Sir,

    Sorry to disturb you.
    I want the Accuracy, Precision,Recall as output or confusion matrix as output  after combining the the two confusion matrix using Naive Bayes combination method.
    How can I implement it in rapidminer? or is there any other tool?
    I need to complete it in 2 days.

    Please Sir reply me

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

    that is not a development question. Please post that question here: http://rapid-i.com/rapidforum/index.php/board,5.0.html

    Regards,
    Marco
Sign In or Register to comment.