public Weight(String feature, Vector weights, int n) { this.feature = feature; // pick out the weight with the largest abs value, but don't forget the sign Queue<Category> biggest = new PriorityQueue<>(n + 1, Ordering.natural()); for (Vector.Element element : weights.all()) { biggest.add(new Category(element.index(), element.get())); while (biggest.size() > n) { biggest.poll(); } } categories = new ArrayList<>(biggest); Collections.sort(categories, Ordering.natural().reverse()); value = categories.get(0).weight; maxIndex = categories.get(0).index; }
public Weight(String feature, Vector weights, int n) { this.feature = feature; // pick out the weight with the largest abs value, but don't forget the sign Queue<Category> biggest = new PriorityQueue<Category>(n + 1, Ordering.natural()); for (Vector.Element element : weights.all()) { biggest.add(new Category(element.index(), element.get())); while (biggest.size() > n) { biggest.poll(); } } categories = Lists.newArrayList(biggest); Collections.sort(categories, Ordering.natural().reverse()); value = categories.get(0).weight; maxIndex = categories.get(0).index; }
public Weight(String feature, Vector weights, int n) { this.feature = feature; // pick out the weight with the largest abs value, but don't forget the sign Queue<Category> biggest = new PriorityQueue<Category>(n + 1, Ordering.natural()); for (Vector.Element element : weights.all()) { biggest.add(new Category(element.index(), element.get())); while (biggest.size() > n) { biggest.poll(); } } categories = Lists.newArrayList(biggest); Collections.sort(categories, Ordering.natural().reverse()); value = categories.get(0).weight; maxIndex = categories.get(0).index; }