"how to write my JAVA application by learning the XML from RM"
gfyang
New Altair Community Member
Hi, I am beginning to integrate RM into my own application.
First of all, I want to implement the following by java codes,
Thank you very much.
First of all, I want to implement the following by java codes,
This is what I know:
<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>
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?
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);
Thank you very much.
0
Answers
-
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,
Steffen0 -
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,
The accuracy is stored in PerformanceVector, but how to println this double value?
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;
Sincerely yours,
gfyang
0 -
Hello gfyang
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.
process.run().get(PerformanceVector.class).getCriterion("accuracy").getAverage();
regards,
Steffen0 -
Thank you very much0