Orange Forum • View topic - AttributeError

AttributeError

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

AttributeError

Postby jasonzutty » Tue Jan 14, 2014 18:11

Hi Everyone,

I am getting a new error I have not seen before:

self.orange = Orange.data.Table(domain, instances)
AttributeError: Converting arrays of type 'S' is not supported (use one of 'bBhHiIlLfdc')

My domain, as far as I can tell, is well formed to my instances. What might I check for to determine the cause of this error?

Thanks,
Jason

Re: AttributeError

Postby jasonzutty » Tue Jan 14, 2014 20:47

Ok, so I have done some more digging, and more specifically, here is my issue.

I have a discrete class, and my features represented as a numpy array. I was creating an instance by concatenating the features with a column vector representing the class variable. This matrix became my instances matrix.

The problem is that discrete variables are symbolic, and represented as strings (am I right about this restriction?), so when I run the concatenation, numpy casts the matrix as a string. Well, the rest of the features are supposed to have continuous attributes, so this breaks down I believe.

What are my options for resolving this issue?

Thanks,
Jason

Re: AttributeError

Postby Ales » Wed Jan 15, 2014 15:08

jasonzutty wrote:The problem is that discrete variables are symbolic, and represented as strings (am I right about this restriction?), so when I run the concatenation
They can also be represented as integers (indices into the feature.values list).
However because the numpy matrices must be of homogeneous type the Table constructor also accepts floats as indices (it will round them to the nearest integer).

For instance:
Code: Select all
import Orange
import numpy
iris_domain = Orange.data.Table("iris").domain
data = Orange.data.Table(iris_domain, numpy.array([[5.1, 3.5, 1.4, 0.2, 0.0], [7.0, 3.2, 4.7, 1.4, 1.0]]))
(note that passing the same values as plain list of lists would not work here)

Re: AttributeError

Postby jasonzutty » Fri Mar 07, 2014 22:12

But when I try to build a discrete feature for the domain out of a list of possible integers using:
Orange.feature.Discrete('class', values=class_list)
I get:
*** TypeError: invalid parameter type for 'Orange.feature.Discrete.values', (expected 'Orange.core.StringList', got 'list')

Any ideas why that might be?

Re: AttributeError

Postby Ales » Tue Mar 11, 2014 10:24

jasonzutty wrote:But when I try to build a discrete feature for the domain out of a list of possible integers using:
Orange.feature.Discrete('class', values=class_list)
I get:
*** TypeError: invalid parameter type for 'Orange.feature.Discrete.values', (expected 'Orange.core.StringList', got 'list')

The 'values' parameter must be a list of strings not integers.


Return to Questions & Support