Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String pluralityValue(List<Instance> instances, DataSet train){
- int[] labelsCount = new int[train.labels.size()];
- for(Instance instance : instances){
- labelsCount[instance.label]++;
- }
- int maxLabelCount = -1;
- int maxLabelIndex = -1;
- for(int i = 0; i < labelsCount.length; i++){
- if(labelsCount[i] > maxLabelCount){
- maxLabelCount = labelsCount[i];
- maxLabelIndex = i;
- }
- }
- return train.labels.get(maxLabelIndex);
- }
Advertisement
Add Comment
Please, Sign In to add comment