diff --git a/Orange/classification/rules.py b/Orange/classification/rules.py index c4e6b3a6357..db9baf1395c 100644 --- a/Orange/classification/rules.py +++ b/Orange/classification/rules.py @@ -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) @@ -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