如何在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的优秀资源就在这里!
- 静态方法访问非静态构造函数?
- 获取类的所有方法的新方法是什么,包括Java 8的inheritance默认方法?
- ClassNotFoundException:org.hibernate.hql.internal.ast.HqlToken甚至在添加了classic.ClassicQueryTranslatorFactory 之后
- 为什么ZipInputStream无法读取ZipOutputStream的输出?
- 如何在Java Swing中控制JTextField的宽度?
- 递归BeanUtils.describe()
- 如何解决此错误java.util.ConcurrentModificationException
- Netbeans在保存时部署:它应该如何工作?
- HTTP状态400 – 必需字符串参数“xx”不存在