testnaivebayes.java

来自「这是一个用于测试用的搜索引擎的案例」· Java 代码 · 共 39 行

JAVA
39
字号
package ir.classifiers;import java.util.*;/** * Wrapper class to test NaiveBayes classifier using 10-fold CV. * Running it with -debug option gives very detailed output * * @author       Sugato Basu */public class TestNaiveBayes {    /** A driver method for testing the NaiveBayes classifier using    * 10-fold cross validation.      * @param args a list of command-line arguments.  Specifying "-debug"    * will provide detailed output    */    public static void main(String args[]) throws Exception    {	String dirName = "/u/mooney/ir-code/corpora/yahoo-science/";	String[] categories = {"bio","chem","phys"};	System.out.println("Loading Examples from " + dirName + "...");	List examples = new DirectoryExamplesConstructor(dirName, categories).getExamples();	System.out.println("Initializing Naive Bayes classifier...");	NaiveBayes BC;	boolean debug;	// setting debug flag gives very detailed output, suitable for debugging	if (args.length==1 && args[0].equals("-debug"))	    debug = true;	else	    debug = false;	BC = new NaiveBayes(categories, debug);	// Perform 10-fold cross validation to generate learning curve	CVLearningCurve cvCurve = new CVLearningCurve(BC,examples);	cvCurve.run();    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?