/docs/reference/rst/code/rules-cn2.py

https://bitbucket.org/tadej_janez/orange-distribute · Python · 20 lines · 7 code · 4 blank · 9 comment · 1 complexity · 4700f1f431926d478eef4d078634e443 MD5 · raw file

  1. # Description: CN2 Rule Induction on Titanic dataset
  2. # Category: classification
  3. # Uses: titanic
  4. # Referenced: Orange.classification.rules
  5. # Classes: Orange.classification.rules.CN2Learner
  6. import Orange
  7. # Read some data
  8. table = Orange.data.Table("titanic")
  9. # construct the learning algorithm and use it to induce a classifier
  10. cn2_learner = Orange.classification.rules.CN2Learner()
  11. cn2_clasifier = cn2_learner(table)
  12. # ... or, in a single step.
  13. cn2_classifier = Orange.classification.rules.CN2Learner(table)
  14. # All rule-base classifiers can have their rules printed out like this:
  15. for r in cn2_classifier.rules:
  16. print Orange.classification.rules.rule_to_string(r)