classifier.java

来自「一个使用的搜索引擎」· Java 代码 · 共 48 行

JAVA
48
字号
package ir.classifiers;import java.util.*;import ir.vsr.*;/** * Abstract class specifying the functionality of a classifier. Provides methods for  * training and testing a classifier * * @author       Sugato Basu */public abstract class Classifier {         /** Array of categories (classes) in the data */    protected String[] categories;    /** To be overloaded by the extending class */    public abstract String getName();    public String[] getCategories() {	return categories;    }    /** Trains the classifier on the training examples */    public abstract void train(List trainingExamples);        /** Returns true if the predicted category of the test example matches the correct category,	false otherwise */    public abstract boolean test(Example testExample);    /** Returns the array index with the maximum value      * @params Array whose index with max value has to be found     */    protected int argMax(double[] results){	int maxIndex = 0;	double max = results[0];		for(int i=1;i<results.length;i++){	    if(results[i]>max){		max=results[i];		maxIndex = i;	    }	}	return(maxIndex);    }}

⌨️ 快捷键说明

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