lamiastella

Untitled

Oct 10th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. private static String pluralityValue(List<Instance> instances, DataSet train){
  2.         int[] labelsCount = new int[train.labels.size()];
  3.         for(Instance instance : instances){
  4.             labelsCount[instance.label]++;
  5.         }
  6.         int maxLabelCount = -1;
  7.         int maxLabelIndex = -1;
  8.         for(int i = 0; i < labelsCount.length; i++){
  9.             if(labelsCount[i] > maxLabelCount){
  10.                 maxLabelCount = labelsCount[i];
  11.                 maxLabelIndex = i;
  12.             }
  13.         }
  14.         return train.labels.get(maxLabelIndex);
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment