I want to display information from RowInstance
. The following code snippets display most attributes.
# type(line) is Orange.data.table.RowInstance
for i, cell in enumerate(line.values()):
print(cell.value)
However, "metadata values" are not accessible from the method values()
. Only the feature values are returned.
How can I access metadata from RowInstance
?
I found one way to read the metadata attributes
The Domain property contains the attributes list and the metadata list.
>>> line.domain.attributes[0].name
"Feature1"
>>> line.domain.metas[0].name
"Metadata1"
The domain also has an utility function that get the attributes/meta index from its name. This lead to the discovery that metadata values are located in the negative indexes (-1,-2,-3,...).
>>> line.domain.index("Feature1")
0
>>> line.domain.index("Metadata1")
-1
With the index, it is then possible to get the value for the RowInstance
(line variable).
>>> line[0]
Value('Feature1', Hello)
>>> line[0].value
"Hello"
>>> line[-2].value
4.0
Ref : https://docs.orange.biolab.si/3/data-mining-library/reference/data.domain.html