如何在eclipse java中重用从explorer(在weka中)创建的已保存分类器

我在WEKA中创建了一个分类器,我将它保存在我的硬盘上,现在我想在eclipse中使用weka api来使用该分类器。

我怎样才能做到这一点? 请指导我…谢谢

以下是加载模型以预测实例值的示例。 示例模型是在Weka Explorer中创建并保存的J48决策树。 它是根据Weka提供的名义天气数据建造的。 它被称为“tree.model”。

//load model String rootPath="/some/where/"; Classifier cls = (Classifier) weka.core.SerializationHelper.read(rootPath+"tree.model"); //predict instance class values Instances originalTrain= //load or create Instances to predict //which instance to predict class value int s1=0; //perform your prediction double value=cls.classifyInstance(originalTrain.instance(s1)); //get the name of the class value String prediction=originalTrain.classAttribute().value((int)value); System.out.println("The predicted value of instance "+ Integer.toString(s1)+ ": "+prediction); 

这个输出是:

 The predicted value of instance 0: no 

Weka api和Serialization的优秀资源就在这里!