My problem is exactly what the title says: I have a numpy array of integers and wish to convert it into an Orange table with discrete values. If I follow these steps, it fails:
import numpy as np
import Orange
a = np.arange(100).reshape((10,10)).astype(np.int8)
fields = ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten')
d = Orange.data.Domain([Orange.feature.Discrete(x) for x in fields])
t = Orange.data.Table(d, a)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-230-f9b4755dcfba> in <module>()
----> 1 t = Orange.data.Table(d, a)
ValueError: Invalid value for a Discrete variable.
I don't wish to use an intermediate physical file (to be honest I tried using a "virtual" file through cStringIO.StringIO but I couldn't pass it correctly as an argument to Orange.data.Table(), since it expects the file name, not the file).
Is there something I can do to achieve it (apart form the intermediate physical file which is one obvious-but-not-elegant-at-all solution)?
PS I've tried also reshaping the numpy array into string, but it errs by giving:
AttributeError: Converting arrays of type 'S' is not supported (use one of 'bBhHiIlLfdc')