Quasars / orange-spectroscopy

Other
51 stars 59 forks source link

Getting Table Info (non-data) in Python Script #339

Closed EmmeWilliams closed 5 years ago

EmmeWilliams commented 5 years ago

Hello,

This may be an issue for Orange in general, but I'm currently dealing with spectroscopy. I have a Python Script connected to a Data Table with collected spectrum data. However the table is set up, I can see the time the data was taken and the name of the data. Is there a way to print out that info specifically? Example below. I want to be able to store the info that it's CaSO4. This is a .0 file, if it matters. Spectra Table

markotoplak commented 5 years ago

Hello. The info is in a meta attribute. You can access it from .metas of a row, so in your case, i.metas. Does it work?

I am closing this PR, but feel free to continue the conversation.

EmmeWilliams commented 5 years ago

That works, thanks. I have a related question. Looking at the liver spectroscopy dataset, the type is given. .metas doesn't work in this case. How can I access the type?

markotoplak commented 5 years ago

Orange data tables have .X (normal features), .Y (target variables), .metas (additional descriptors not used for clustering/model induction). You can see these categories in Select Columns.

For liver spectroscopy the type is therefore in .Y.

EmmeWilliams commented 5 years ago

Thank you. Doing that gives me numerical values corresponding to the type (0,1,2,3) instead of the actual name (DNA, collagen, lipid, glycogen). Can I change this?

markotoplak commented 5 years ago

In this case, it is easier to look from the other direction. See this example:

data = Orange.data.Table("iris")
print(str(data[0][data.domain.class_var]))
stuart-cls commented 5 years ago

I find the information in https://orange.biolab.si/docs/, specifically https://docs.biolab.si//3/data-mining-library/#reference invaluable for this type of question. I hope that helps.