Orange Forum • View topic - Evaluate one instance of data in classifier

Evaluate one instance of data in classifier

A place to ask questions about methods in Orange and how they are used and other general support.

Evaluate one instance of data in classifier

Postby Gray » Tue Apr 03, 2012 15:10

I am new to python and to Orange as well. By now I was able to create function which loads data from a list and creates tree classifier.
Now I want to write other function which will use this classifier to classify one instance of new data. What is the best approach to this. Do I really need to load this one data instance into a Table object and then use features from Evaluate class ? Aren't there any methods in classifier to help me do the job without creating Table and refering to Evaluate?

Re: Evaluate one instance of data in classifier

Postby Ales » Tue Apr 03, 2012 15:23

You don't need 'evaluate' module, just call the classifier with the new instance.
Code: Select all
import Orange
iris = Orange.data.Table("iris")
tree_l = Orange.classification.tree.TreeLearner()
tree_c = tree_l(iris)
# classifiy a new instance (the last "?" is the unknown class)
new_instance = Orange.data.Instance(iris.domain, [5.6, 3.7, 1.3, 0.0, "?"])
print tree_c(new_instance)
Notice that you will need to construct an instance of the same domain that was used in the training step.

Re: Evaluate one instance of data in classifier

Postby Gray » Tue Apr 03, 2012 15:38

Thanks for a lightning fast and crystal clear reply :) Turns out everything is very simple and straightforward. I am loving Orange more and more with every bite of it .


Return to Questions & Support