def __induce_level(self, rules):
        '''
        Specializes the rules for the last level with unary predicates.
        '''
        while True:
            old_score = self.group_score(rules)
            new_rules = rules[:]
            for i, rule in enumerate(rules):
                specializations = self.specialize(rule)
                self.extend(new_rules, specializations)

            # Take the first N rules
            rules = sorted(new_rules,
                           key=lambda rule: rule.score,
                           reverse=True)[:self.n]

            new_score = self.group_score(rules)

            logger.debug("Old score: %.3f, New score: %.3f" % (old_score, new_score))

            if 1 - abs(old_score/(new_score+0.0001)) < 0.01:
                break

        return rules
dataset/ETHPy150Open anzev/hedwig/hedwig/learners/learner.py/Learner.__induce_level/original