def generate_negative_rules_by_rule_cover_number(self, train, confident_value_pass, zone_confident_pass): class_value_arr = self.get_class_value_array(train) self.prepare_data_rows(train) for i in range(0, len(self.rule_base_array)): rule_negative = Rule(self.data_base) rule_negative.antecedent = self.rule_base_array[i].antecedent positive_rule_class_value = self.rule_base_array[i].get_class() print("the positive rule class value is " + str(positive_rule_class_value) + " ,the i is :" + str(i)) # rule_negative.setClass(positive_rule_class_value) best_rule_cover_accurate = self.rule_base_array[i].rule_cover_accurate has_negative_rule = False for j in range(0, len(class_value_arr)): class_type = int(class_value_arr[j]) if positive_rule_class_value != class_type: # need to get another class value for negative rule rule_negative.calculate_confident_support(self.data_row_array) print("Negative rule's confident value is :" + str(rule_negative.confident_value)) if rule_negative.rule_cover_accurate > best_rule_cover_accurate: best_negative_rule = rule_negative.clone() best_negative_rule.setClass(class_type) # change the class type in the rule best_negative_rule.negative_rule = True has_negative_rule = True if (not (self.duplicated_negative_rule(rule_negative))) and has_negative_rule: for k in range(0, len(rule_negative.antecedent)): print("antecedent L_ " + str(rule_negative.antecedent[j])) # print("Negative rule's class value " + str(rule_negative.get_class())) # print(" Negative rule's weight, confident_vale " + str(rule_negative.weight)) # print(" Negative rule's zone confident value " + str(rule_negative.zone_confident)) # print("Negative rule's positive_rule_class_value" + str(positive_rule_class_value)) # print("Negative rule's class_type" + str(class_type)) self.rule_base_array.pop(i) self.rule_base_array.append(best_negative_rule)