Commit c3f06cc7 authored by Daniel Schlör's avatar Daniel Schlör
Browse files

changed break condition

parent 7376acfe
......@@ -103,6 +103,10 @@ public class MatrixMapping {
return denseIndexToFeaturesMapping.get(densePoint);
}
public HashMap<Point, Set<Point>> getDenseIndexToFeaturesMapping() {
return denseIndexToFeaturesMapping;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
......
......@@ -217,7 +217,7 @@ public class BinaryRepresentationRuleLearningAlgorithm implements IRepresentatio
// assert that the maximum is growing
assert (maximumScore <= iterationMatrix.getMaximumScore()) : "Maximum decreased within iteration!";
if (!betterRuleCanBeLearned(maximumScore, iterationMatrix)) {
if (!betterRuleCanBeLearned(mappings.get(mappings.size() - 2), mappings.get(mappings.size() - 1))) {
mappings.remove(mappingForMaximum);
break;
}
......@@ -242,7 +242,17 @@ public class BinaryRepresentationRuleLearningAlgorithm implements IRepresentatio
maximumScore, (maxEntryLocation.getTp() / (maxEntryLocation.getFp() + maxEntryLocation.getTp())));
}
// TODO isnt this too greedy?
private boolean betterRuleCanBeLearned(MatrixMapping lastMapping, MatrixMapping newMapping) {
Set<Set<Point>> lastFeatures = new HashSet<Set<Point>>(lastMapping.getDenseIndexToFeaturesMapping().values());
Set<Set<Point>> newFeatures = new HashSet<Set<Point>>(newMapping.getDenseIndexToFeaturesMapping().values());
// TODO: is this really all we need?
if (lastFeatures.equals(newFeatures)) {
return false;
}
return true;
}
private boolean betterRuleCanBeLearned(int maximumScore, MatrixMcMatrixFace matrixInFocus) {
if (matrixInFocus.getMaximumScore() > maximumScore) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment