Skip to content
Snippets Groups Projects
Verified Commit 0812ae51 authored by David Procházka's avatar David Procházka
Browse files

FIX: performance measures take algorithm representing the input tree

parent 3c2d8472
No related branches found
No related tags found
No related merge requests found
package mhtree.benchmarking;
import messif.algorithms.Algorithm;
import messif.algorithms.AlgorithmMethodException;
import messif.objects.util.DistanceRankedObject;
import messif.objects.util.RankedAbstractObject;
import messif.operations.query.ApproxKNNQueryOperation;
import messif.operations.query.KNNQueryOperation;
import messif.utility.reflection.NoSuchInstantiatorException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -16,13 +16,9 @@ import java.util.stream.Collectors;
public class PerformanceMeasures {
public static double measureErrorOnThePosition(ApproxKNNQueryOperation approxKNNQueryOperation, Tree tree) {
public static double measureErrorOnThePosition(ApproxKNNQueryOperation approxKNNQueryOperation, Algorithm tree) throws NoSuchMethodException, AlgorithmMethodException {
KNNQueryOperation rankedObjects = new KNNQueryOperation(approxKNNQueryOperation.getQueryObject(), tree.getObjectCount());
try {
tree.kNN(rankedObjects);
} catch (ClassNotFoundException | NoSuchInstantiatorException | InvocationTargetException e) {
e.printStackTrace();
}
tree.executeOperation(rankedObjects);
Map<String, Integer> IDtoPosition = new HashMap<>(rankedObjects.getAnswerCount());
......@@ -44,15 +40,11 @@ public class PerformanceMeasures {
}
// comparing done based on distances, counts how many of the same distances of KNNQueryOperation were presents in the answer of ApproxKNNQueryOperation
public static double measureRecall(ApproxKNNQueryOperation approxKNNQueryOperation, Tree tree) {
public static double measureRecall(ApproxKNNQueryOperation approxKNNQueryOperation, Algorithm tree) throws NoSuchMethodException, AlgorithmMethodException {
if (approxKNNQueryOperation.getAnswerCount() == 0) return 0d;
KNNQueryOperation knnQueryOperation = new KNNQueryOperation(approxKNNQueryOperation.getQueryObject(), approxKNNQueryOperation.getK());
try {
tree.kNN(knnQueryOperation);
} catch (ClassNotFoundException | NoSuchInstantiatorException | InvocationTargetException e) {
e.printStackTrace();
}
tree.executeOperation(knnQueryOperation);
List<RankedAbstractObject> objects = new ArrayList<>(knnQueryOperation.getAnswerCount());
for (RankedAbstractObject object : knnQueryOperation)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment