Decision tree classification without process in JAVA

justinkrausejustinkrause MemberPosts:3Contributor I
edited June 2019 inHelp

Hi,

I have trained my decision tree in RM and now want to load it in my Java application. Once loaded I want to be able to classificate an example (as long as my application is alive). But I do not want to use a process because this would need to reload the model every time. That would not be efficient.

For example:

private String classificate(double[] attributes){

//Create a classification given these attributes

return classification;

}

Right now I have something like this:

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

Operator modelReader = OperatorService.createOperator(ModelLoader.class);
modelReader.setParameter("model_file", "C:/Users/birdman/Desktop/TreeModel.mod");

Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
InputPort inApply = modelApplier.getInputPorts().getAllPorts().get(0);
modelReader.getOutputPorts().getAllPorts().get(0).connectTo(inApply);

modelReader.execute();

modelApplier.execute();

Now I need an operator which has an output linking to the modelApplier's input to generate a classification.

How do I do this? Is this even the right way to realize this?

Thanks in advance,

BM

    Sign InorRegisterto comment.