RAPIDMINER 9.7 BETA ANNOUNCEMENT

The beta program for the RapidMiner 9.7 release is now available. Lots of amazing new improvements including true version control!

CLICK HERE TO DOWNLOAD

RapidMiner 4.6 Operator.getOutputPorts/getInputPorts + OutputPort/InputPort

Pedro_NevesPedro_Neves Member Posts: 4 Contributor I
edited November 2018 in Help
Hi there, i'm having some problems in integrating rapidminer in my Java application  :(. So far I have a model of a trained neural network i created on rapidminer 4.6 (Not using rapidminer 5.3 because i get some errors on rapidminer.init() ). Now in my code i have to load the CSV file (which is the test dataset), load my NeuralNetwork model and apply it. Something like this (an example i found online):
public ApplyModel(String modelFile, String unlabelledFile){
     
    try {
           
            RapidMiner.init();

            com.rapidminer.Process processo = new com.rapidminer.Process();

            System.out.println(unlabelledFile);

            Operator csvReader = OperatorService.createOperator(com.rapidminer.operator.io.CSVExampleSource.class);
            System.out.println(unlabelledFile);
            csvReader.setParameter(com.rapidminer.operator.io.CSVExampleSource.PARAMETER_FILENAME, unlabelledFile);  //test File
            csvReader.setParameter(com.rapidminer.operator.io.CSVExampleSource.PARAMETER_COLUMN_SEPARATORS, ",");
            csvReader.setParameter(com.rapidminer.operator.io.CSVExampleSource.PARAMETER_TRIM_LINES, "true");
            csvReader.setParameter(com.rapidminer.operator.io.CSVExampleSource.PARAMETER_READ_ATTRIBUTE_NAMES, "true");
           
            [glow=red,2,300]OutputPort[/glow] portaSaidaLeitorCSV = csvReader.[glow=red,2,300]getOutputPorts()[/glow].getPortByName("output");
           
            Operator ReadModelOperator = OperatorService.createOperator(ModelLoader.class);
            ReadModelOperator.setParameter("model_file", modelFile);
            [glow=red,2,300]OutputPort[/glow] portaSaidaCarregadorModelo = ReadModelOperator.[glow=red,2,300]getOutputPorts()[/glow].getPortByName("output");
           
            Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
            modelApplier.setParameter("keep_model", "false");
          [glow=red,2,300] InputPort [/glow]portaEntrada1AplicadorModelo = modelApplier.[glow=red,2,300]getInputPorts()[/glow].getPortByName("model");
            [glow=red,2,300]InputPort[/glow] portaEntrada2AplicadorModelo = modelApplier.[glow=red,2,300]getInputPorts()[/glow].getPortByName("unlabelled data");

            ExampleSet resultSet = processo.run().get(ExampleSet.class);
            Iterator it = resultSet.iterator();
           
            System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
            while (it.hasNext()) {
                Example e = (Example) it.next();
                String predLabelIndex = e.getDataRow().toString();
                System.out.println(predLabelIndex);
            }
            System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
       
    } catch (OperatorException ex) {
        Logger.getLogger(ApplyModel.class.getName()).log(Level.SEVERE, null, ex);
    } catch (OperatorCreationException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    }
However, i dont know what to import for the highlighted lines work (Cannot find the package or class file properly). If i comment this lines i get an error when i'm getting the ExampleSet (on Bold).
Maybe this is a Newbie question but i'm kinda new in rapidminer  :-\. 

Thanks in Advance
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,928   RM Engineering
    Hi,

    RapidMiner 4 is two major versions behind and thus not supported any longer. Instead I would advise you to fix the init() problem and then use RM 5.3.

    Regards,
    Marco
Sign In or Register to comment.