Skip to content

Commit

Permalink
Fixed very rare bug of model being dependent on the order in the nomi…
Browse files Browse the repository at this point in the history
…nal attribute mapping.
  • Loading branch information
agudys committed Mar 25, 2024
1 parent 1f93637 commit 1636f2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion adaa.analytics.rules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ codeQuality {
}

sourceCompatibility = 1.8
version = '1.7.6'
version = '1.7.7'


jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ class TotalPosNeg {
quality = modifier.modifyQuality(quality, attr.getName(), p, toCover_p);
// prefer (gender = female) over (gender = !male) for boolean attributes
if (quality > best.quality ||
(quality == best.quality && (p > best.covered || best.opposite))) {
(quality == best.quality && (p > best.covered || (p == best.covered && best.opposite)))) {
ElementaryCondition candidate =
new ElementaryCondition(attr.getName(), new SingletonSet((double) i, attr.getMapping().getValues()));
if (checkCandidate(candidate, classId, p, n, toCover_p, P, uncoveredPositives.size(), rule.getRuleOrderNum())) {
Expand Down Expand Up @@ -741,7 +741,8 @@ class TotalPosNeg {
for (Future f : futures) {
ConditionEvaluation eval = (ConditionEvaluation)f.get();

Logger.log("\tAttribute best: " + eval.condition + ", quality=" + eval.quality + "\n", Level.FINEST);
Logger.log("\tAttribute best: " + eval.condition + ", quality=" + eval.quality
+ ", p=" + eval.covered + "\n", Level.FINEST);

if (best == null || eval.quality > best.quality || (eval.quality == best.quality && eval.covered > best.covered)) {
best = eval;
Expand All @@ -755,7 +756,8 @@ class TotalPosNeg {
if (best.condition != null) {
Attribute bestAttr = trainSet.getAttributes().get(((ElementaryCondition)best.condition).getAttribute());

Logger.log("\tFinal best: " + best.condition + ", quality=" + best.quality + "\n", Level.FINEST);
Logger.log("\tFinal best: " + best.condition + ", quality=" + best.quality
+ ", p=" + best.covered + "\n", Level.FINEST);

if (bestAttr.isNominal()) {
allowedAttributes.remove(bestAttr);
Expand Down

0 comments on commit 1636f2b

Please sign in to comment.