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
RapidMiner 4.6 Operator.getOutputPorts/getInputPorts + OutputPort/InputPort
Pedro_Neves
Member Posts: 4 Contributor I
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):
Maybe this is a Newbie question but i'm kinda new in rapidminer :-\.
Thanks in Advance
public ApplyModel(String modelFile, String unlabelledFile){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).
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);
}
}
Maybe this is a Newbie question but i'm kinda new in rapidminer :-\.
Thanks in Advance
Tagged:
0
Answers
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