Example: ZeroR (Majority Class)
public class ZeroR extends DistributionClassifier implements WeightedInstancesHandler {
private double m_ClassValue; //The class value 0R predicts
private double [] m_Counts; //The number of instances in each class
public void buildClassifier(Instances instances) throws Exception {
m_Counts = new double [instances.numClasses()];
for (int i = 0; i < m_Counts.length; i++) { //Initialize counts
Enumeration enum = instances.enumerateInstances();
while (enum.hasMoreElements()) { //Add up class counts
Instance instance = (Instance) enum.nextElement();
m_Counts[(int)instance.classValue()] += instance.weight();
m_ClassValue = Utils.maxIndex(m_Counts); //Find majority class
Utils.normalize(m_Counts); } //Normalize counts