Can I use Orange CN2 classifier to learn rules for one class only?

1.4k views Asked by At

I am using Orange CN2 rule induction algorithm for fraud detection where fraud rate is very low (below 0.1%). By default CN2 learns rules for both classes (Fraud and Non-Fraud). As I am interested in Fraud class rules only, learning of Non-Fraud rules is a waste of time especailly considering I need to run CN2 on many datasets. Is it possible for CN2 to learn only Fraud class rules and if yes, how to configure it in the script to do this? Thanks!

1

There are 1 answers

0
Nitram On BEST ANSWER

The CN2UnorderedLearner class that you are using is based on the basic orange rulelearner, that, in fact, already learns rules for one class only. To learn one class only you need to specify the target_class and call the parent class. Something like that:

cn2_learner.target_class = 0 # you can change this to get other classes
cn2_classifier = Orange.classification.rules.RuleLearner.__call__(cn2_learner, train, 0)
#cn2_classifier = cn2_learner(train)

for r in cn2_classifier.rules:
    print Orange.classification.rules.rule_to_string(r)