How do I create a new data table in Orange?

点点圈 提交于 2019-12-12 08:12:43

问题


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)        

回答1:


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.




回答2:


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/



来源:https://stackoverflow.com/questions/8986719/how-do-i-create-a-new-data-table-in-orange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!