Skip to content

Commit

Permalink
Fix: Rules failed when new_rules empty
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Apr 20, 2020
1 parent 3e2d432 commit c3b2c78
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Orange/classification/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,11 @@ def __str__(self):
else:
cond = "TRUE"

outcome = class_var.name + "=" + class_var.values[self.prediction]
# it is possible that prediction is not set yet - use _ for outcome
outcome = (
(class_var.name + "=" + class_var.values[self.prediction])
if self.prediction is not None else "_"
)
return "IF {} THEN {} ".format(cond, outcome)


Expand Down Expand Up @@ -870,8 +874,8 @@ def rcmp(rule):
new_rules = self.search_strategy.refine_rule(
X, Y, W, candidate_rule)
rules.extend(new_rules)
#remove default rule from list of rules
if best_rule.length == 0:
# remove default rule from list of rules
if best_rule.length == 0 and len(new_rules) > 0:
best_rule = new_rules[0]
for new_rule in new_rules[1:]:
if (new_rule.quality > best_rule.quality and
Expand Down

0 comments on commit c3b2c78

Please sign in to comment.