Orange Forum • View topic - orange.ContingencyAttrClass Kernel Exception

orange.ContingencyAttrClass Kernel Exception

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

orange.ContingencyAttrClass Kernel Exception

Postby x0ner » Mon Apr 16, 2012 7:28

I am currently working on a classifier and ran across this error:

orange.KernelException: 'orange.ContingencyAttrClass': index 11615 is out of range 0-11566

My classifier is built off of a 17K line dataset with 25 attributes per line. The dataset I am looking to classify also has 25 attributes and is only 475 lines in size. Is this error being thrown because of the complexity introduced by the large amount of attributes?

Re: orange.ContingencyAttrClass Kernel Exception

Postby Ales » Mon Apr 16, 2012 10:13

Can you provide more details.
Are you using the ContingencyAttrClass directly in your code or does this error happen using some other method/class? How exactly are you using this?

Re: orange.ContingencyAttrClass Kernel Exception

Postby x0ner » Mon Apr 16, 2012 14:26

Apologies, I meant to add that last night before signing off.

Here is the code:
Code: Select all
import orange
data = orange.ExampleTable("data/23attr/complete")
classifier = orange.BayesLearner(data)

bad = 0
good = 0

ex = orange.ExampleTable("data/23attr/tl")

for example in ex[:10]:
   c = classifier(example)
   if c == 1:
      bad = bad + 1
   else:
      good = good + 1

print "total bad: " + str(bad)
print "total good: " + str(good)


The classifier is that taking in the 17K. When I test it against itself, it works fine and I get no error. However, when I test it against a brand new dataset (my unclassified set) then I get that error.

Re: orange.ContingencyAttrClass Kernel Exception

Postby Ales » Mon Apr 16, 2012 16:21

Can you try loading the 'data/23attr/tl' dataset before training the classifier.
The error is most probably caused by http://orange.biolab.si/doc/reference/Orange.feature.descriptor/#reuse-of-descriptors, i.e. a discrete variable in the test dataset has values which are not found (or listed) in the training dataset.

You can also load and then re-save both the datasets as a .tab file. This has the added effect of listing all of the values in the file header
Code: Select all
complete = orange.ExampleTable("data/23attr/complete")
test= orange.ExampleTable("data/23attr/tl")
complete.save("data/23attr/complete-with-desc.tab")
test.save("data/23attr/tl-with-desc.tab")

Re: orange.ContingencyAttrClass Kernel Exception

Postby x0ner » Mon Apr 16, 2012 16:47

That did the trick! So even with the data matching format-wise, this could still happen? Is there a general best practice for the loading and unloading of data to catch these sort of problems or does it just come with running into them?

I have actually had my data saved in TAB format, but it didn't appear that I needed to include the extension when loading the information. As a last question, when sending data to the classifier, does it NEED to be in the same format? For example, my test data won't have a class since I don't know it, so should the column exist?


Return to Questions & Support



cron