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 write my JAVA application by learning the XML from RM"

gfyanggfyang Member Posts: 29 Maven
edited May 2019 in Help
Hi, I am beginning to integrate RM into my own application.
First of all,  I want to implement the following by  java codes,

<operator name="Root" class="Process" expanded="yes">
    <operator name="ArffExampleSource" class="ArffExampleSource">
        <parameter key="data_file" value="../data/iris.arff"/>
        <parameter key="label_attribute" value="class"/>
    </operator>
    <operator name="SimpleValidation" class="SimpleValidation" expanded="yes">
        <operator name="NaiveBayes" class="NaiveBayes">
        </operator>
        <operator name="ApplierChain" class="OperatorChain" expanded="yes">
            <operator name="Test" class="ModelApplier">
                <list key="application_parameters">
                </list>
            </operator>
            <operator name="Performance" class="Performance">
            </operator>
        </operator>
    </operator>
</operator>
This is what I know:

RapidMiner.init();

//read the data
Operator inputData = OperatorService.createOperator(ArffExampleSource.class);
inputData.setParameter("data_file", "C:/data/iris.arff");
inputData.setParameter("label_attribute", "class");
IOContainer container = inputData.apply(new IOContainer());

//build the model
OperatorChain simpleValidate =
(OperatorChain) OperatorService.createOperator("SimpleValidation");
OperatorChain applierChain =
(OperatorChain) OperatorService.createOperator("ApplierChain");

Operator naiveBayes = OperatorService.createOperator("NaiveBayes");
Operator test = OperatorService.createOperator("ModelApplier");
Operator performance = OperatorService.createOperator("Performance");

applierChain.addOperator(test);
applierChain.addOperator(performance);
simpleValidate.addOperator(naiveBayes);
simpleValidate.addOperator(applierChain);
Of course, it does not work. How could I really make the application run? That is, inputting data, validating naive bayes, and then outputting the accuracy?

Thank you very much.
Tagged:

Answers

  • steffensteffen Member Posts: 347 Maven
    Hello gfyang

    There is a file called "rapidminer-<version>-tutorial.pdf" which you download from the rapidminer page at sourceforge (http://sourceforge.net/projects/yale/files/). In this you can find a chapter "Integrating RapidMiner into your application" where everything is explained.

    If you have further questions, do not hesitate to ask.

    regards,

    Steffen
  • gfyanggfyang Member Posts: 29 Maven
    Hi, Steffen,

    Thanks a lot for the reply. I have found the tutorial, and it is very helpful.

    I build a complete process. However, I do not know how to get the value of the testing result (not from the console).
    For example,

    RapidMiner.init();

    Process process = new Process();

    //read the data
    Operator inputData = OperatorService.createOperator(ArffExampleSource.class);
    inputData.setParameter("data_file", "C:/data/iris.arff");
    inputData.setParameter("label_attribute", "class");

    //build the model
    OperatorChain simpleValidate =
    (OperatorChain) OperatorService.createOperator("SimpleValidation");
    Operator naiveBayes = OperatorService.createOperator("NaiveBayes");
    OperatorChain applierChain =
    (OperatorChain) OperatorService.createOperator("OperatorChain");
    Operator test = OperatorService.createOperator("ModelApplier");
    Operator performance = OperatorService.createOperator("Performance");
    applierChain.addOperator(test);
    applierChain.addOperator(performance);
    simpleValidate.addOperator(naiveBayes);
    simpleValidate.addOperator(applierChain);

    process.getRootOperator().addOperator(inputData);
    process.getRootOperator().addOperator(simpleValidate);

    // how to get the accuracy?
    // double accuracy = ???

    return process;
    The accuracy is stored in PerformanceVector, but how to println this double value?

    Sincerely yours,
    gfyang
  • steffensteffen Member Posts: 347 Maven
    Hello gfyang

    process.run().get(PerformanceVector.class).getCriterion("accuracy").getAverage();
    I you want to use the accuracy within the process, you have to implement your own operator (for this task there is also a chapter in the tutorial) and retrieve the performancevector from this operator's input.

    regards,

    Steffen
  • gfyanggfyang Member Posts: 29 Maven
    Thank you very much  :)
Sign In or Register to comment.