I'm trying to use the java machine learning library MOA to train on a training data stream, then predict classes for a test data stream. The first part works fine, using (for example)
java -cp .:moa.jar:weka.jar -javaagent:sizeofag.jar moa.DoTask "LearnModel -l MajorityClass -s (ArffFileStream -f atrain.arff -c -1) -O amodel.moa"
But then I cannot figure out how to use the trained model (amodel.moa) on another 开发者_StackOverflowstream (atest.arff) to predict the classes. Has anyone done this before?
Try to use "EvaluateModel" with the -m option:
java -cp .:moa.jar:weka.jar -javaagent:sizeofag.jar moa.DoTask "EvaluateModel -m file:amodel.moa -s (ArffFileStream -f atest.arff -c -1) "
It might be easiest just to use the Weka wrapper for MOA classifiers:
java -cp .:moa.jar:weka.jar -javaagent:sizeofag.jar weka.classifiers.meta.MOA -B moa.classifiers.NaiveBayes -t atrain.arff -d amodel.model
java -cp .:moa.jar:weka.jar -javaagent:sizeofag.jar weka.classifiers.meta.MOA -T atest.arff -l amodel.model -p 4
Where of course -p
indicates the column to predict.
精彩评论