🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

RapidMiner/Netbeans Integration problem!

User: "tonio6"
New Altair Community Member
Updated by Jocelyn
Hello guys,
I have a serioous issue and i need your help...I've created a calss in my program which creates a rapidminer model by adding each operator of rapidminer directly in netbeans rather than loading a complete model from rapidminer program. But now i get an error which looks like that :

.....
....
Rmtest 0
Dec 08, 2013 10:25:00 PM youcomment.gui btRMtestActionPerformed
SEVERE: null
com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.text.io.FileDocumentInputOperator'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:687)
at youcomment.RapidM.runthisthingy(RapidM.java:96)
at youcomment.gui.btRMtestActionPerformed(gui.java:217)
......
.....
.....

so actually the error appears after i print the "Rmtest 0" thing...in this line of code i suppose:
" FileDocumentInputOperator processdocumentfromfiles1 = OperatorService.createOperator(FileDocumentInputOperator.class)"

I add the whole class i made...pls help me out here i am not an expert java programmer but i am trying to learn!!! thank you a lot...


package youcomment;

import com.rapidminer.Process;
import com.rapidminer.RapidMiner;
import com.rapidminer.RapidMiner.ExecutionMode;
import com.rapidminer.example.Attribute;
import com.rapidminer.example.Example;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.example.table.ExampleTable;
import com.rapidminer.operator.ExecutionUnit;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.ModelApplier;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorCreationException;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.operator.performance.PerformanceEvaluator;
import com.rapidminer.operator.validation.XValidation;
import com.rapidminer.operator.text.io.*;
import com.rapidminer.operator.learner.bayes.NaiveBayes;
import com.rapidminer.operator.performance.BinominalClassificationPerformanceEvaluator;
import com.rapidminer.tools.OperatorService;
import com.rapidminer.operator.text.io.DocumentLoader;
import com.rapidminer.operator.text.io.DocumentTextInputOperator;
import com.rapidminer.operator.text.io.tokenizer.StringTokenizerOperator;
import com.rapidminer.operator.text.io.transformer.CaseTransformationOperator;
import java.io.*;
import java.util.List;
import java.util.LinkedList;

public class RapidM {

    /**
    * Connect the output-port
    * <code>fromPortName</code> from Operator
    * <code>from</code> with the input-port
    * <code>toPortName</code> of Operator
    * <code>to</code>.
    */
    private static void connect(Operator from, String fromPortName, Operator to, String toPortName) {
        from.getOutputPorts().getPortByName(fromPortName).connectTo(to.getInputPorts().getPortByName(toPortName));
    }

    /**
    * Connect the output-port
    * <code>fromPortName</code> from Subprocess
    * <code>from</code> with the input-port
    * <code>toPortName</code> of Operator
    * <code>to</code>.
    */
    private static void connect(ExecutionUnit from, String fromPortName,
            Operator to, String toPortName) {
        from.getInnerSources().getPortByName(fromPortName).connectTo(
                to.getInputPorts().getPortByName(toPortName));
    }

    /**
    * Connect the output-port
    * <code>fromPortName</code> from Operator
    * <code>from</code> with the input-port
    * <code>toPortName</code> of Subprocess
    * <code>to</code>.
    */
    private static void connect(Operator from, String fromPortName,
            ExecutionUnit to, String toPortName) throws OperatorCreationException, IOException, OperatorException {

        from.getOutputPorts().getPortByName(fromPortName).connectTo(
                to.getInnerSinks().getPortByName(toPortName));}

        public void runthisthingy() throws OperatorCreationException, IOException, OperatorException{
       
        //initialiaze rapiminer
            // set properties to point to plugin directory
      String pluginDirString = new File("C:\\Program_Files\\Rapid-I\\RapidMiner5\\lib\\plugins").getAbsolutePath();
      System.setProperty(RapidMiner.PROPERTY_RAPIDMINER_INIT_PLUGINS_LOCATION, pluginDirString);
        RapidMiner.setExecutionMode(ExecutionMode.EMBEDDED_WITHOUT_UI);
        RapidMiner.init();

        // Create a process
        Process process = new Process();

        // Set the parameters of process
        process.getRootOperator().setParameter("parallelize_main_process", "true");
        process.getRootOperator().setParameter("encoding", "UTF-8");

        // all operators from "left to right"
System.out.println("Rmtest 0");
        //Process documents from files
        FileDocumentInputOperator processdocumentfromfiles1 = OperatorService.createOperator(FileDocumentInputOperator.class);
        System.out.println("Rmtest 1");
        //set textlist of Process documents from files
        List<String[]> textList1 = new LinkedList<String[]>();

        textList1.add(new String[]{"Positive", "positive"});
        textList1.add(new String[]{"Negative", "negative"});


        System.out.println("Rmtest 2");
        textList1.add(new String[]{"Positive", "positive"});
        System.out.println("Rmtest 3");
        textList1.add(new String[]{"Negative", "negative"});
            System.out.println("Rmtest 4");

        // Set the parameters of Process documents from files 1
        processdocumentfromfiles1.setListParameter("text_directories", textList1);
        processdocumentfromfiles1.setParameter("encoding", "UTF-8");
        processdocumentfromfiles1.setParameter("vector_creation", "TF-IDF");
        processdocumentfromfiles1.setParameter("prune_method", "absolute");
        processdocumentfromfiles1.setParameter("prune_below_absolute", "2");
        processdocumentfromfiles1.setParameter("prune_above_absolute", "999");
        processdocumentfromfiles1.setParameter("parallelize_vector_creation","true");
        //X-validation
        XValidation xvalidation = OperatorService.createOperator(XValidation.class);

        // Set the parameters of X-validation
        xvalidation.setParameter(XValidation.PARAMETER_NUMBER_OF_VALIDATIONS, Integer.valueOf(10).toString());
        xvalidation.setParameter("parallelize_training", "true");
        xvalidation.setParameter("parallelize_testing", "true");

        //Operators inside the validation
        NaiveBayes naivebayes = OperatorService.createOperator(NaiveBayes.class);
        //naivebayes.setParameter("training_cycles", "500");
        //RandomForestLearner ManolisRF=OperatorService.createOperator(RandomForestLearner.class);


        Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
        BinominalClassificationPerformanceEvaluator performance = OperatorService.createOperator(BinominalClassificationPerformanceEvaluator.class);

        //Process documents from files
        FileDocumentInputOperator processdocumentfromfiles2 = OperatorService.createOperator(FileDocumentInputOperator.class);

        //set textlist of Process documents from files
        List<String[]> textList2 = new LinkedList<String[]>();
        textList2.add(new String[]{"Unlabeled", "unlabeled"});
       

        // Set the parameters of Process documents from files 2
        processdocumentfromfiles2.setListParameter("text_directories", textList2);
        processdocumentfromfiles2.setParameter("encoding", "UTF-8");
        processdocumentfromfiles2.setParameter("vector_creation", "TF-IDF");
        processdocumentfromfiles2.setParameter("prune_method", "absolute");
        processdocumentfromfiles2.setParameter("prune_below_absolute", "2");
        processdocumentfromfiles2.setParameter("prune_above_absolute", "999");
        processdocumentfromfiles2.setParameter("parallelize_vector_creation","true");
       
        // add operators to the main process and connect them
        process.getRootOperator().getSubprocess(0).addOperator(processdocumentfromfiles1);
        process.getRootOperator().getSubprocess(0).addOperator(xvalidation);
        connect(processdocumentfromfiles1, "example set", xvalidation, "training");

        //operators  inside the process documents from files 1
        StringTokenizerOperator tokenize1 = OperatorService.createOperator(StringTokenizerOperator.class);
        CaseTransformationOperator tranformcases1 = OperatorService.createOperator(CaseTransformationOperator.class);
        // add operators to the process documents from files and connect them
        processdocumentfromfiles1.getSubprocess(0).addOperator(tokenize1);
        processdocumentfromfiles1.getSubprocess(0).addOperator(tranformcases1);

        connect(processdocumentfromfiles1.getSubprocess(0), "document", tokenize1, "document");
        connect(tokenize1, "document", tranformcases1, "document");
        connect(tranformcases1, "document", processdocumentfromfiles1.getSubprocess(0), "document 1");

        // xvalidation
        // training part of xvalidation
        xvalidation.getSubprocess(0).addOperator(naivebayes);
        //xvalidation.getSubprocess(0).addOperator(ManolisRF);

        // create connection within training process: from left to right ...
        connect(xvalidation.getSubprocess(0), "training", naivebayes, "training set");

        //connect(xvalidation.getSubprocess(0), "training", ManolisRF,"training set");
        connect(naivebayes, "model", xvalidation.getSubprocess(0), "model");
        //connect(ManolisRF, "model", modelWriter, "input");

        // testing part of xvalidation
        xvalidation.getSubprocess(1).addOperator(modelApplier);
        xvalidation.getSubprocess(1).addOperator(performance);

        // create connection within testing process: from left to right ...
        connect(xvalidation.getSubprocess(1), "model", modelApplier, "model");
        connect(xvalidation.getSubprocess(1), "test set", modelApplier, "unlabelled data");
        connect(modelApplier, "labelled data", performance, "labelled data");
        connect(performance, "performance", xvalidation.getSubprocess(1), "averagable 1");

      // add operators to the main process and connect them
        process.getRootOperator().getSubprocess(0).addOperator(processdocumentfromfiles2);
        connect(processdocumentfromfiles1, "word list", processdocumentfromfiles2, "word list");

        //operators  inside the process documents from files
        StringTokenizerOperator tokenize2 = OperatorService.createOperator(StringTokenizerOperator.class);
        CaseTransformationOperator tranformcases2 = OperatorService.createOperator(CaseTransformationOperator.class);
        // add operators to the process documents from files and connect them
        processdocumentfromfiles2.getSubprocess(0).addOperator(tokenize2);
        processdocumentfromfiles2.getSubprocess(0).addOperator(tranformcases2);

        connect(processdocumentfromfiles2.getSubprocess(0), "document", tokenize2, "document");
        connect(tokenize2, "document", tranformcases2, "document");
        connect(tranformcases2, "document", processdocumentfromfiles2.getSubprocess(0), "document 1");

        // add operators to the main process and connect them
       
        process.getRootOperator().getSubprocess(0).addOperator(modelApplier);
       
        connect(processdocumentfromfiles2, "example set", modelApplier, "unlabelled data");
        connect(xvalidation, "model", modelApplier, "model");
        connect(modelApplier, "labelled data", process.getRootOperator().getSubprocess(0), "result 1");
        connect(modelApplier, "model", process.getRootOperator().getSubprocess(0), "result 2");

        // print process setup
        //System.out.println(process.getRootOperator().createProcessTree(0));

        File x = new File("Final.rmp");

        process.save(x);

        // perform process
        //process.run();
        IOContainer ioResult = process.run();
       
    }
}

Find more posts tagged with