"Problem using OperatorChain(ROCBasedComparisonOperator) from java ?"

shiva_cse1986
shiva_cse1986 New Altair Community Member
edited November 2024 in Community Q&A
How to use OperatorChain from java .for eg ROCBasedComparisonOperator

I am using this for generating ROC curve for an input arff file using NaiveBayes Learner.

Here goes my code->



           RapidMiner.init();
           com.rapidminer.Process process = new Process();

           Operator readArff = OperatorService.createOperator(ArffExampleSource.class);
           readArff.setParameter(ArffExampleSource.PARAMETER_DATA_FILE, "D:/rm/campaign-classification-traindata.arff");
           OutputPort readArffOutputPort = readArff.getOutputPorts().getPortByName("output");

           Operator attributes = OperatorService.createOperator(ChangeAttributeRole.class);
           attributes.setParameter("name", "opened");
           attributes.setParameter("target_role", "label");
           InputPort attributesInputPort = attributes.getInputPorts().getPortByName("example set input");
           OutputPort attributesOutputPort = attributes.getOutputPorts().getPortByName("example set output");
           readArffOutputPort.connectTo(attributesInputPort);
           
           Operator algorithm = OperatorService.createOperator(NaiveBayes.class);
           InputPort algorithmInputPort = algorithm.getInputPorts().getPortByName("training set");
           OutputPort algorithmOutPort = algorithm.getOutputPorts().getPortByName("model");
           
           
           Operator rocCompop = OperatorService.createOperator(ROCBasedComparisonOperator.class);
           OperatorChain rocCompChain = (OperatorChain)rocCompop;
           rocCompChain.getSubprocess(0).addOperator(algorithm);
           
           InputPort rocCompInputPort = rocCompChain.getInputPorts().getPortByName("example set");            
           attributesOutputPort.connectTo(rocCompInputPort);
           
           process.getRootOperator().getSubprocess(0).addOperator(readArff);
           process.getRootOperator().getSubprocess(0).addOperator(attributes);
           process.getRootOperator().getSubprocess(0).addOperator(rocCompChain);

           rocCompChain.doWork();
           process.run();
           Collection<OutputPort> ioc = process.getRootOperator().getSubprocess(0).getAllOutputPorts();



Problem running this.here goes my stacktrace->
com.rapidminer.operator.UserError: No data was deliverd at port Compare ROCs.example set.
at com.rapidminer.operator.ports.impl.AbstractPort.getData(AbstractPort.java:79)
at com.rapidminer.operator.visualization.ROCBasedComparisonOperator.doWork(ROCBasedComparisonOperator.java:108)

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • land
    land New Altair Community Member
    Hi,
    if the chain is part of a process which you want execute, you mustn't start the chain itself by calling doWork(). If you do, the previous operators aren't executed and hence did not deliver data.

    Greetings,
      Sebastian
  • shiva_cse1986
    shiva_cse1986 New Altair Community Member
    @Sebastian,thank ypu for the reply.

    I even tried without explicictly calling doWork() method of OperatorChain ie.ROCBasesCamparisonOperator,even then exception is thrown saying that "No data is delivered input port of the NaiveBayes Operator"

    Exception raised is :-

    com.rapidminer.operator.UserError: No data was deliverd at port Naive Bayes.training set.
    at com.rapidminer.operator.ports.impl.AbstractPort.getData(AbstractPort.java:79)
    at com.rapidminer.operator.learner.AbstractLearner.doWork(AbstractLearner.java:134)
    at com.rapidminer.operator.Operator.execute(Operator.java:771)
    at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
    at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:709)
    at com.rapidminer.operator.visualization.ROCBasedComparisonOperator.doWork(ROCBasedComparisonOperator.java:159)
    at com.rapidminer.operator.Operator.execute(Operator.java:771)
    at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
    at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:709)
    at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:368)
    at com.rapidminer.operator.Operator.execute(Operator.java:771)
    at com.rapidminer.Process.run(Process.java:899)
    at com.rapidminer.Process.run(Process.java:795)
    at com.rapidminer.Process.run(Process.java:790)
    at com.rapidminer.Process.run(Process.java:780)

    ***************************
    Sebastian, can u plz give a sample program demonstarting the use of OperatorChains.
    ***************************
  • land
    land New Altair Community Member
    Hi,
    sorry, but you will have to wait for the integration guide. I'm rather busy right now and I can't just use one hour for making a good example.

    Greetings,
      Sebastian

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.