You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Orange中从RowInstance读取元属性?

Accessing Metadata from Orange.data.table.RowInstance

Great question! The values() method on Orange.data.table.RowInstance only returns feature values—metadata is stored separately in the metas attribute of the row. Let's break down how to access it properly:

Basic Metadata Value Access

You can iterate over metadata values directly using line.metas, just like you did with values(). Each entry in line.metas is a metadata cell, and you can extract its value with .value (same as you did for feature cells):

# type(line) is Orange.data.table.RowInstance
# Print feature values (your original code)
print("Feature Values:")
for i, cell in enumerate(line.values()):
    print(cell.value)

# Print metadata values
print("\nMetadata Values:")
for i, meta_cell in enumerate(line.metas):
    print(meta_cell.value)

Access Metadata with Variable Names

If you want to pair metadata values with their corresponding variable names (instead of just raw values), you can use the row's domain object. The domain's metas list contains definitions for all metadata variables, so you can zip them together with the row's metadata cells:

# Get the domain from the row's associated data table
domain = line.domain

print("Metadata with Names:")
for meta_var, meta_cell in zip(domain.metas, line.metas):
    print(f"{meta_var.name}: {meta_cell.value}")

This way you'll get clear, labeled metadata values instead of just a list of unlabeled entries.

内容的提问来源于stack exchange,提问作者h3xStream

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:47:13