首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Weka开发[二]-分类器类

2013-04-20 
Weka开发[2]-分类器类package com.cizito.weka.studyimport weka.classifiers.bayes.NaiveBayesimport w

Weka开发[2]-分类器类
package com.cizito.weka.study;import weka.classifiers.bayes.NaiveBayes;import weka.classifiers.functions.SMO;import weka.classifiers.trees.J48;import weka.core.Instances;import weka.core.converters.ConverterUtils.DataSource;/** * @author zhangwei * */public class ClassifierTest {private Instances m_instances = null;/** * @param args */public static void main(String[] args) throws Exception{ClassifierTest ctest = new ClassifierTest(); ctest.getFileInstances( "D:/ProgramFiles/Weka-3-6/data/contact-lenses.arff"); ctest.classify();} public void getFileInstances( String fileName ) throws Exception { DataSource frData = new DataSource( fileName ); m_instances = frData.getDataSet(); m_instances.setClassIndex( m_instances.numAttributes()-1); } public void classify() throws Exception { //J48 classifier = new J48(); NaiveBayes classifier = new NaiveBayes(); //SMO classifier = new SMO(); classifier.buildClassifier( m_instances ); System.out.println( classifier.classifyInstance( m_instances.instance( 0 ) ) ); } }

?

热点排行