// sort the list
// TODO understand logits!!
//  remove 1 counts!
private List<Pair<Object, Double>> getMostInfluentialFeatures(Label clazz, FeatureVector featureVector) {
        assert this.model instanceof NaiveBayesModel;
        NaiveBayesModel myModel = (NaiveBayesModel) this.model;
        List<Pair<Object, Double>> mostInfluentialFeatures = new ArrayList<>();
        for (Object feature : featureVector) {
            double classConditional = myModel.computeClassConditionalProbability(feature, clazz);
            if (useLogits)
                classConditional = -Math.log(classConditional);
            mostInfluentialFeatures.add(Pair.of(feature, classConditional));
        }
        // sort the list
        // TODO understand logits!!
        //  remove 1 counts!
        if (useLogits)
            mostInfluentialFeatures.sort(Comparator.comparing(Pair::getRight));
        else
            mostInfluentialFeatures.sort((o1, o2) -> o2.getRight().compareTo(o1.getRight()));
        return mostInfluentialFeatures.subList(0, mostInfluentialFeatures.size() <= numberOfInfluentialFeatures ? mostInfluentialFeatures.size() - 1 : numberOfInfluentialFeatures);
    }
mostInfluentialFeatures.add(Pair.of(feature, classConditional));
}
// sort the list
// TODO understand logits!!
// remove 1 counts!
if (useLogits)
mostInfluentialFeatures.sort(Comparator.comparing(Pair::getRight));
private List<Pair<Object, Double>> getMostInfluentialFeatures(Label clazz, FeatureVector featureVector) {
assert this.model instanceof NaiveBayesModel;
NaiveBayesModel myModel = (NaiveBayesModel) this.model;
List<Pair<Object, Double>> mostInfluentialFeatures = new ArrayList<>();
for (Object feature : featureVector) {
double classConditional = myModel.computeClassConditionalProbability(feature, clazz);
if (useLogits)
classConditional = -Math.log(classConditional);
mostInfluentialFeatures.add(Pair.of(feature, classConditional));
}
// sort the list
// TODO understand logits!!
// remove 1 counts!
if (useLogits)
mostInfluentialFeatures.sort(Comparator.comparing(Pair::getRight));
else
mostInfluentialFeatures.sort((o1, o2) -> o2.getRight().compareTo(o1.getRight()));
return mostInfluentialFeatures.subList(0, mostInfluentialFeatures.size() <= numberOfInfluentialFeatures ? mostInfluentialFeatures.size() - 1 : numberOfInfluentialFeatures);
}
private List<Pair<Object, Double>> getMostInfluentialFeatures(Label clazz, FeatureVector featureVector) {
assert this.model instanceof NaiveBayesModel;
NaiveBayesModel myModel = (NaiveBayesModel) this.model;
List<Pair<Object, Double>> mostInfluentialFeatures = new ArrayList<>();
for (Object feature : featureVector) {
double classConditional = myModel.computeClassConditionalProbability(feature, clazz);
if (useLogits)
classConditional = -Math.log(classConditional);
mostInfluentialFeatures.add(Pair.of(feature, classConditional));
}
// sort the list
// TODO understand logits!!
// remove 1 counts!
if (useLogits)
mostInfluentialFeatures.sort(Comparator.comparing(Pair::getRight));
else
mostInfluentialFeatures.sort((o1, o2) -> o2.getRight().compareTo(o1.getRight()));
return mostInfluentialFeatures.subList(0, mostInfluentialFeatures.size() <= numberOfInfluentialFeatures ? mostInfluentialFeatures.size() - 1 : numberOfInfluentialFeatures);
}