Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a new data table in Orange?

I am using Orange (in Python) for some data mining tasks. More specifically, for clustering. Although I have gone through the tutorial and read most of the documentation, I still have a problem. All the examples in docs and tutorials assume that I have a tab delimited table with data in it. However, there is nothing saying how one can go about creating a new table from scratch. For example, I want to create a table for word frequencies across different documents.

Maybe I am missing something so if anyone has any insight it'd be appreciated.

Thanks George

EDIT:

This is how I create my table

#First construct the domain object (top row)
vars = []
for var in variables:
    vars.append(Orange.data.variable.Continuous(str(var)))
domain = Orange.data.Domain(vars, classed) #The second argument indicated that the last attr must not be a class    
#Add data rows assuming we have a matrix 
t = Orange.data.Table(domain, matrix)        
like image 769
George Eracleous Avatar asked Jan 24 '12 12:01

George Eracleous


2 Answers

This took me hours to figure out. In python, do this:

Import Orange
List, Of, Column, Variables = [Orange.feature.Discrete(x) for x in ['What','Theyre','Called','AsStrings']]
Domain = Orange.data.Domain([List, Of, Column, Variables])
Table = Orange.data.Table(Domain)
Table.save('NewTable.tab')

I'd tell you what each bit of code does, but as of now I'm not really sure. It's funny that such a powerful toolkit should have such hard to understand documentation, but I suspect it's because it's entire user base has doctorates.

like image 175
N. McA. Avatar answered Sep 22 '22 12:09

N. McA.


The documentation is indeed insufficient if you ask me. This may not be the answer to the question but it could be helpful to someone else. I tried for hours to create a Table using constructors and Domains and what not, just for an association rule mining task, and finally found out that the easiest way to create a table is simply to write your data to a file with the extension .tab or .basket and create a table from that.

Orange.data.Table("yourFile.basket")

Of course the structure of the file needs to be correct. See the provided example files located in the Orange package directory inside datasets/

like image 20
user1114496 Avatar answered Sep 19 '22 12:09

user1114496