I am using RM 4.6 to transform data for RM using my own application data directly as input.
Figure 7.4 (shown below) in rapidMiner-4.6-tutorial.pdf gives an example of classifier training and inference. For learning
Model model = learner. learn (exampleSet);
uses an ExampleSet object as input, section 7.6 tells how to do the data transformation for this object class. However, for inference,
container = modelApp.apply(container);
uses an IOContainer object as input. But I cannot find any source from the tutorial that tells how to transform data to this object class.
So how can we do the data transform for the object class in inference stage?
By the way, besides the code below from Figure 7.4 that tells how to train and test a classifier, is there any other methods and sample code that do this?Any comment is greatly appreciated!
public static void main(String [] args) {
try {
RapidMiner. init ();
// learn
Operator exampleSource =
OperatorService . createOperator(ExampleSource.class);
exampleSource.setParameter(” attributes ”,
”/path/to/your/training data .xml”);
IOContainer container = exampleSource.apply(new IOContainer());
ExampleSet exampleSet = container.get(ExampleSet.class);
// here the string based creation must be used since the J48 operator
// do not have an own class ( derived from the Weka library ).
Learner learner = (Learner)OperatorService . createOperator(”J48”);
Model model = learner. learn (exampleSet);
// loading the test set ( plus adding the model to result container )
Operator testSource =
OperatorService . createOperator(ExampleSource.class);
testSource .setParameter(” attributes ”, ”/path/to/your/test data .xml”);method and
container = testSource.apply(new IOContainer());
container = container.append(model);
// applying the model
Operator modelApp =
OperatorService . createOperator(ModelApplier. class );
container = modelApp.apply(container);
// print results
ExampleSet resultSet = container. get(ExampleSet.class );
Attribute predictedLabel = resultSet . getPredictedLabel ();
ExampleReader reader = resultSet.getExampleReader();
while (reader .hasNext()) {
System.out. println (reader .next (). getValueAsString( predictedLabel ));
}
} catch (IOException e) {
System.err . println (”Cannot initialize RapidMiner:” + e.getMessage());
} catch (OperatorCreationException e) {
System.err . println (”Cannot create operator:” + e.getMessage());
} catch (OperatorException e) {
System.err . println (”Cannot create model: ” + e.getMessage());
}
}