"CSVDataReader Error: No operator description object"
wannin0
New Altair Community Member
Good day!!
I am currently programming including RapidMiner in a Java application. It is supposed to read a model and a csv file. These will be the inputs for ModelApplier.
To read the csv file, I used CSVDataReader. But when I compile my program, this error occured:
2011-03-24 21:54:24 SEVERE: null (ApplyModel.<init>())
com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.io.CSVDataReader'
Here is the source code:
Regards,
Jarren
I am currently programming including RapidMiner in a Java application. It is supposed to read a model and a csv file. These will be the inputs for ModelApplier.
To read the csv file, I used CSVDataReader. But when I compile my program, this error occured:
2011-03-24 21:54:24 SEVERE: null (ApplyModel.<init>())
com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.io.CSVDataReader'
Here is the source code:
Would someone please guide me why I am committing this error? Any help would be appreciated.
import com.rapidminer.RapidMiner;
import com.rapidminer.example.Example;
import com.rapidminer.example.ExampleSet;
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.io.CSVDataReader;
import com.rapidminer.tools.OperatorService;
import com.rapidminer.operator.io.ModelLoader;
import com.rapidminer.operator.nio.CSVExampleSource;
import com.rapidminer.operator.ports.InputPort;
import com.rapidminer.operator.ports.OutputPort;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ApplyModel {
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(CSVDataReader.class);
System.out.println(unlabelledFile);
csvReader.setParameter(CSVDataReader.PARAMETER_CSV_FILE, unlabelledFile);
csvReader.setParameter(CSVDataReader.PARAMETER_COLUMN_SEPARATORS, ",");
csvReader.setParameter(CSVDataReader.PARAMETER_TRIM_LINES, "true");
csvReader.setParameter(CSVDataReader.PARAMETER_USE_FIRST_ROW_AS_ATTRIBUTE_NAMES, "true");
OutputPort portaSaidaLeitorCSV = csvReader.getOutputPorts().getPortByName("output");
Operator ReadModelOperator = OperatorService.createOperator(ModelLoader.class);
ReadModelOperator.setParameter("model_file", modelFile);
OutputPort portaSaidaCarregadorModelo = ReadModelOperator.getOutputPorts().getPortByName("output");
Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
modelApplier.setParameter("keep_model", "false");
InputPort portaEntrada1AplicadorModelo = modelApplier.getInputPorts().getPortByName("model");
InputPort portaEntrada2AplicadorModelo = modelApplier.getInputPorts().getPortByName("unlabelled data");
ExampleSet resultSet = processo.run().get(ExampleSet.class);
Iterator it = resultSet.iterator();
while (it.hasNext()) {
Example e = (Example) it.next();
String predLabelIndex = e.getDataRow().toString();
System.out.println(predLabelIndex);
}
} 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);
}
}
}
Regards,
Jarren
0
Answers
-
I know the error is at
Operator csvReader = OperatorService.createOperator(CSVDataReader.class);
I just don't know why?
0 -
Hi,
because you are referring the wrong class. Use "com.rapidminer.operator.nio.CSVDataReader" instead.
Greetings,
Sebastian0 -
Thanks!! Was able to successfully run it in Java :D0