📄 classifier.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -