@Test public void testTwoUnequalClassInformation() { assertEquals(0.5623351446188083, Information.entropy(new int[] {2, 6})); }
public static double entropy(int[] counts) { double entropy = 0.0; int total = 0; for (int count : counts) { if (count > 1) { entropy -= count * Math.log(count); } total += count; } return entropy / total + Math.log(total); }
Information { public static double entropy(int[] counts) { double entropy = 0.0; int total = 0; for (int count : counts) { if (count > 1) { entropy -= count * Math.log(count); } total += count; } return entropy / total + Math.log(total); } }
Information { public static double entropy(int[] counts) { double entropy = 0.0; int total = 0; for (int count : counts) { if (count > 1) { entropy -= count * Math.log(count); } total += count; } return entropy / total + Math.log(total); } private  Information(); }
Information { public static double entropy(int[] counts) { double entropy = 0.0; int total = 0; for (int count : counts) { if (count > 1) { entropy -= count * Math.log(count); } total += count; } return entropy / total + Math.log(total); } private  Information(); static Pair<Decision,Double> bestGain(Iterable<Decision> decisions, ExampleSet examples); static double entropy(int[] counts); }
Information { public static double entropy(int[] counts) { double entropy = 0.0; int total = 0; for (int count : counts) { if (count > 1) { entropy -= count * Math.log(count); } total += count; } return entropy / total + Math.log(total); } private  Information(); static Pair<Decision,Double> bestGain(Iterable<Decision> decisions, ExampleSet examples); static double entropy(int[] counts);  }