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
Getting a null pointer while trying to write a model using ModelWriter
Legacy User
Member Posts: 0 Newbie
Hello,
I am trying to use rapidminer as a library. I'm trying something very simple to begin with. I read in a training data set, generate a model, and write the model out. I have been successful in doing this in the GUI, but it seems to fail when I try to do it progmatically. Here is my code:
I am trying to use rapidminer as a library. I'm trying something very simple to begin with. I read in a training data set, generate a model, and write the model out. I have been successful in doing this in the GUI, but it seems to fail when I try to do it progmatically. Here is my code:
I tried to follow the manual when writing that code. Here is the error produced
public class Collect
{
public static void main(String[] args)
{
RapidMiner.init();
try
{
Operator input = OperatorService.createOperator(ArffExampleSource.class);
input.setParameter("data_file", "/home/vahid/Desktop/c_training.arff");
input.setParameter("label_attribute", "change");
IOContainer io = input.apply(new IOContainer());
ExampleSet exampleSet = io.get(ExampleSet.class);
Learner learner = (Learner) OperatorService.createOperator(NaiveBayes.class);
Model model = learner.learn(exampleSet);
ModelWriter writer = (ModelWriter) OperatorService.createOperator(ModelWriter.class);
writer.setParameter("model_file", "/home/model.mod");
writer.setParameter("overwrite_existing_file", "true");
writer.setParameter("output_type", "XML");
writer.apply();
}
catch (OperatorCreationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperatorException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Any help is appreciated
Exception in thread "main" java.lang.NullPointerException
at com.rapidminer.operator.Operator.getInput(Operator.java:821)
at com.rapidminer.operator.Operator.getInput(Operator.java:802)
at com.rapidminer.operator.io.ModelWriter.apply(ModelWriter.java:96)
at Collect.main(Collect.java:33)
0
Answers
I think you forgot to tell the ModelWriter what to write out. Try this (not tested): regards,
Steffen
Thanks for the help though!
What I meant was: It is no good idea to think about this stuff so late in the evening.
regards,
Steffen