Orange Forum • View topic - Ambiguous Error From Bayes Classifier

Ambiguous Error From Bayes Classifier

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

Ambiguous Error From Bayes Classifier

Postby jasonzutty » Tue Mar 05, 2013 19:48

The error I received is:
Code: Select all
TypeError: wrong attribute value (expected value of 'class', got value of 'class')


This is coming from the code:
Code: Select all
learner = Orange.classification.bayes.NaiveLearner()
classifier = learner(trainData)
for d in testData:
     d.set_class(classifier(d))


Both testData, trainData are orange tables.

Any insights here would be greatly appreciated!

Thanks,
Jason

Re: Ambiguous Error From Bayes Classifier

Postby jasonzutty » Tue Mar 05, 2013 20:58

It can be noted that in further debugging d.get_class() might return
<orange.Value 'class'='0'>
and classifier(d) might return
<orange.Value 'class'='0'>
d.set_class(d.get_class()) works fine, but d.set_class(classifier(d)) still produces the error.

Also, if I say
x = classifier(d)
y = d.get_class()
where x and y are the results stated above, x==y returns true....

Re: Ambiguous Error From Bayes Classifier

Postby jasonzutty » Wed Mar 06, 2013 20:21

Thinking about it, and observing some examples, I am not sure the classifiers are working as intended.

In other words if each Orange data table is built independently, and have their own features uniquely (Even though they actually match as in the example I posted with classes), are they being matched up correctly by the algorithms?

Again, an example of how my domain is generated is:
Code: Select all
features = [Orange.feature.Continuous(str(x)) for x in np.arange(self.numpy['features'].shape[1]) ]
classList = [str(x) for x in np.arange(10)]
class_var = Orange.feature.Discrete('class',values=classList)
domain = Orange.data.Domain(features,class_var)

(self.numpy['features'] is a numpy representation of my features)

Thanks,
Jason

Re: Ambiguous Error From Bayes Classifier

Postby Ales » Thu Mar 07, 2013 10:54

See this, in particular the 'Reuse of descriptors section'.

Re: Ambiguous Error From Bayes Classifier

Postby jasonzutty » Thu Mar 07, 2013 15:29

Ok, but I am getting results, so if you wouldn't mind shedding a tad more light.

Here is the domain of my test data
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, class]

Here is an example of a row from my test data.
[25.000, 1.000, 226802.000, 8.000, 13.000, 2.000, 12.000, 1.000, 4.000, 0.000, 0.000, 0.000, 40.000, 1.000, '1']
(The class is set by a bayes classifier, trained from the below data)

Here is the domain of my train data
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, class]

And an example row of the train data is
[39.000, 6.000, 77516.000, 0.000, 4.000, 2.000, 13.000, 3.000, 0.000, 0.000, 2174.000, 0.000, 40.000, 1.000, '1']

Here, everything is generated uniquely, i.e. domains are generated from scratch, so even though names and values are consistent, they are unique.
set_class as stated above, is a no go, so when my fix was to use set_class(classifier(d).value)

My question is, can I trust these results (I am getting outputs from the classifier), or are they giving me disguised garbage?

If I cannot, do you have any recommendations for copying one domain in to another table, translate did not seem to work for me.

Thanks very much,
Jason

Re: Ambiguous Error From Bayes Classifier

Postby Ales » Fri Mar 08, 2013 11:09

jasonzutty wrote:My question is, can I trust these results
Probably not.

jasonzutty wrote:If I cannot, do you have any recommendations for copying one domain in to another table
How are loading/generating the data sets? Always from numpy arrays?
You can just pass an existing domain to the table constructor
Code: Select all
test_data = Orange.data.Table(train_data.domain, array)

Re: Ambiguous Error From Bayes Classifier

Postby jasonzutty » Fri Mar 08, 2013 14:43

Yes, usually from numpy arrays. The results seem to be consistent with what I was getting when I loaded them straight from the TAB files.


Return to Questions & Support



cron