Orange 2.5: code conversion

Orange 2.5 unifies Orange’s C++ core and Python modules into a single module hierarchy. To use the new module hierarchy, import Orange instead of orange and accompanying orng* modules. While we will maintain backward compatibility in 2.* releases, we nevertheless suggest programmers to use the new interface. The provided conversion tool can help refactor your code to use the new interface.

The conversion script,, resides in Orange’s main directory. To refactor from the “Orange for beginners” tutorial runpython -w -o doc/ofb-rst/code/

The old code

import orange
import orngTest, orngStat, orngTree

# set up the learners
bayes = orange.BayesLearner()
tree = orngTree.TreeLearner(mForPruning=2) = "bayes" = "tree"
learners = [bayes, tree]

# compute accuracies on data
data = orange.ExampleTable("voting")
res = orngTest.crossValidation(learners, data, folds=10)
cm = orngStat.computeConfusionMatrices(res,

is refactored to

import Orange

# set up the learners
bayes = Orange.classification.bayes.NaiveLearner()
tree = Orange.classification.tree.TreeLearner(mForPruning=2) = "bayes" = "tree"
learners = [bayes, tree]

# compute accuracies on data
data ="voting")
res = Orange.evaluation.testing.cross_validation(learners, data, folds=10)
cm = Orange.evaluation.scoring.compute_confusion_matrices(res,

Read more about the refactoring tool on the wiki and on the help page (python --help).

Leave a Reply