/** * Main method for testing this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new AdaBoostM1(), argv); } }
/** * Method used to build the classifier. */ public void buildClassifier(Instances data) throws Exception { reset(); // Initialize classifier initializeClassifier(data); // Perform boosting iterations while (next()) { } ; // Clean up done(); }
/** * Method used to build the classifier. */ public void buildClassifier(Instances data) throws Exception { // Initialize classifier initializeClassifier(data); // Perform boosting iterations while (next()) {}; // Clean up done(); }
/** * Default constructor */ public AdaBoostMH() { super(new AdaBoostM1()); }
/** * Gets the current settings of the Classifier. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); if (getUseResampling()) { result.add("-Q"); } result.add("-P"); result.add("" + getWeightThreshold()); if (getResume()) { result.add("-resume"); } Collections.addAll(result, super.getOptions()); return result.toArray(new String[result.size()]); }
if (m_WeightThreshold < 100) { trainData = selectWeightQuantile(m_TrainingData, (double) m_WeightThreshold / 100); } else { trainData = new Instances(m_TrainingData); setWeights(m_TrainingData, reweight);
/** * Gets the current settings of the Classifier. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); if (getUseResampling()) { result.add("-Q"); } result.add("-P"); result.add("" + getWeightThreshold()); Collections.addAll(result, super.getOptions()); return result.toArray(new String[result.size()]); }
/** * Returns a string describing classifier * * @return a description suitable for displaying in the explorer/experimenter * gui */ public String globalInfo() { return "Class for boosting a nominal class classifier using the Adaboost " + "M1 method. Only nominal class problems can be tackled. Often " + "dramatically improves performance, but sometimes overfits.\n\n" + "For more information, see\n\n" + getTechnicalInformation().toString(); }
getCapabilities().testWithFail(data);
/** Creates a default AdaBoostM1 */ public Classifier getClassifier() { return new AdaBoostM1(); }
trainData = selectWeightQuantile(m_TrainingData, (double) m_WeightThreshold / 100); } else { setWeights(m_TrainingData, reweight);
/** * Returns a string describing classifier * * @return a description suitable for displaying in the explorer/experimenter * gui */ public String globalInfo() { return "Class for boosting a nominal class classifier using the Adaboost " + "M1 method. Only nominal class problems can be tackled. Often " + "dramatically improves performance, but sometimes overfits.\n\n" + "For more information, see\n\n" + getTechnicalInformation().toString(); }
/** * Initialize the classifier. * * @param data the training data to be used for generating the boosted * classifier. * @throws Exception if the classifier could not be built successfully */ public void initializeClassifier(Instances data) throws Exception { super.buildClassifier(data); // can classifier handle the data? getCapabilities().testWithFail(data); // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); m_ZeroR = new weka.classifiers.rules.ZeroR(); m_ZeroR.buildClassifier(data); m_NumClasses = data.numClasses(); m_Betas = new double[m_Classifiers.length]; m_NumIterationsPerformed = 0; m_TrainingData = new Instances(data); m_RandomInstance = new Random(m_Seed); if ((m_UseResampling) || (!(m_Classifier instanceof WeightedInstancesHandler))) { // Normalize weights so that they sum to one and can be used as sampling probabilities double sumProbs = m_TrainingData.sumOfWeights(); for (int i = 0; i < m_TrainingData.numInstances(); i++) { m_TrainingData.instance(i).setWeight(m_TrainingData.instance(i).weight() / sumProbs); } } }
/** * Main method for testing this class. * * @param argv the options */ public static void main(String[] argv) { runClassifier(new AdaBoostM1(), argv); } }
/** Creates a default AdaBoostM1 */ public Classifier getClassifier() { return new AdaBoostM1(); }