关于weka的使用————模型的建立
2016-08-03 00:00
267 查看
Classifier m_classifier = new MultilayerPerceptron();
Instances instancesTrain =m.instancesTrain("jdbc:mysql://localhost:3306/test","root","123456",2,"select openings,polite_words,professional_response,dirty_words,confirmation,closings,mark from mark");(该方法请参照上文)
设置最后一列为因变量:
instancesTrain.setClassIndex(instancesTrain.numAttributes()-1);
训练得到模型:
m_classifier.buildClassifier(instancesTrain);
/**
* 保存模型值文件中
* @param m_classifier
* @param path 文件路径
* @throws FileNotFoundException
* @throws IOException
*/
public void saveModel(Classifier m_classifier,String path) throws FileNotFoundException, IOException{
ObjectOutputStream oos = new ObjectOutputStream (new FileOutputStream(path));//"d://test.model"
oos.writeObject(m_classifier);
oos.flush();
oos.close();
}
Instances instancesTrain =m.instancesTrain("jdbc:mysql://localhost:3306/test","root","123456",2,"select openings,polite_words,professional_response,dirty_words,confirmation,closings,mark from mark");(该方法请参照上文)
设置最后一列为因变量:
instancesTrain.setClassIndex(instancesTrain.numAttributes()-1);
训练得到模型:
m_classifier.buildClassifier(instancesTrain);
/**
* 保存模型值文件中
* @param m_classifier
* @param path 文件路径
* @throws FileNotFoundException
* @throws IOException
*/
public void saveModel(Classifier m_classifier,String path) throws FileNotFoundException, IOException{
ObjectOutputStream oos = new ObjectOutputStream (new FileOutputStream(path));//"d://test.model"
oos.writeObject(m_classifier);
oos.flush();
oos.close();
}
相关文章推荐
- 关于建立“高保真模型”的必要性
- 关于使用 CreateThread 建立线程池
- 关于建立“高保真模型”的必要性
- 使用visio建立sql server的数据库模型图
- 关于建立数据仓库应用层的数据模型
- 关于建立“高保真模型”的必要性
- 关于MVC使用Code-First代码优先来先建实体类中间添加新字段不需要重新建立数据库的方法
- 使用EMF建立模型并生成Java代码
- 使用PowerDesigner建立数据库模型
- 如何重覆使用ECO建立的企業邏輯模型
- 使用PowerDesigner建立数据库模型
- 关于使用xml技术建立网站。
- Junit 使用中,关于SessionFactory的建立
- 使用PowerDesigner建立数据库模型
- 如何重覆使用ECO建立的企業邏輯模型
- 关于SOA模型的建立
- 关于使用Visual Studio 2008 建立Setup And Deployment Project(安装与部署项目)制作安装.net 安装程序,插入Custom Actions(自定义动作)的办法
- 使用PowerDesigner建立数据库模型【转】
- 关于Java的内存模型,使用的是尚学堂的图
- 关于使用c#在office建立工具条