/** * Main method. * * @param argv the commandline options */ public static void main(String[] argv) { runClassifier(new VotedPerceptron(), argv); } }
/** * Returns a string describing this classifier * @return a description of the classifier suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "Implementation of the voted perceptron algorithm by Freund and " + "Schapire. Globally replaces all missing values, and transforms " + "nominal attributes into binary ones.\n\n" + "For more information, see:\n\n" + getTechnicalInformation().toString(); }
/** Creates a default VotedPerceptron */ public Classifier getClassifier() { return new VotedPerceptron(); }
getCapabilities().testWithFail(insts); Instance inst = m_Train.instance(i); if (!inst.classIsMissing()) { int prediction = makePrediction(m_K, inst); int classValue = (int) inst.classValue(); if (prediction == classValue) {
/** * Compute a prediction from a perceptron * * @param k * @param inst the instance to make a prediction for * @return the prediction * @throws Exception if computation fails */ private int makePrediction(int k, Instance inst) throws Exception { double result = 0; for (int i = 0; i < k; i++) { if (m_IsAddition[i]) { result += innerProduct(m_Train.instance(m_Additions[i]), inst); } else { result -= innerProduct(m_Train.instance(m_Additions[i]), inst); } } if (result < 0) { return 0; } else { return 1; } }
/** Creates a default VotedPerceptron */ public Classifier getClassifier() { return new VotedPerceptron(); }
getCapabilities().testWithFail(insts); Instance inst = m_Train.instance(i); if (!inst.classIsMissing()) { int prediction = makePrediction(m_K, inst); int classValue = (int) inst.classValue(); if (prediction == classValue) {
/** * Compute a prediction from a perceptron * * @param k * @param inst the instance to make a prediction for * @return the prediction * @throws Exception if computation fails */ private int makePrediction(int k, Instance inst) throws Exception { double result = 0; for (int i = 0; i < k; i++) { if (m_IsAddition[i]) { result += innerProduct(m_Train.instance(m_Additions[i]), inst); } else { result -= innerProduct(m_Train.instance(m_Additions[i]), inst); } } if (result < 0) { return 0; } else { return 1; } }
/** * Main method. * * @param argv the commandline options */ public static void main(String[] argv) { runClassifier(new VotedPerceptron(), argv); } }
sumSoFar += innerProduct(m_Train.instance(m_Additions[i]), inst); } else { sumSoFar -= innerProduct(m_Train.instance(m_Additions[i]), inst);
/** * Returns a string describing this classifier * @return a description of the classifier suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "Implementation of the voted perceptron algorithm by Freund and " + "Schapire. Globally replaces all missing values, and transforms " + "nominal attributes into binary ones.\n\n" + "For more information, see:\n\n" + getTechnicalInformation().toString(); }
sumSoFar += innerProduct(m_Train.instance(m_Additions[i]), inst); } else { sumSoFar -= innerProduct(m_Train.instance(m_Additions[i]), inst);