The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"Problem using OperatorChain(ROCBasedComparisonOperator) from java ?"

shiva_cse1986shiva_cse1986 Member Posts: 2 Contributor I
edited May 2019 in Help
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:

Answers

  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    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_cse1986shiva_cse1986 Member Posts: 2 Contributor I
    @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.
    ***************************
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    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
Sign In or Register to comment.