在使用枚举类型训练时,H2O模型错误地将字段视为数字吗?

时间:2019-05-15 00:27:43

标签: h2o

当训练模型时设置的字段类型为enum时,H2O DRF模型将字段类型视为int会出现问题。

在使用经过训练的DRF模型中的H2O tree API检查某些单个树时,我看到对于明确设置为enum 的某些类型,当训练了模型(即,将熊猫数据框转换为H2OFrame,其中某些字段已通过column_types映射参数设置为特定类型),它们似乎被视为{做类似操作时{1}} s

int

更紧凑

root_node.features
> observe that the feature being examined for this node is one of the features set to be categorical enum by the H2OFrame that the model was trained on
tree.root_node.features
> some_categorical
tree.root_node.levels
> []
root_node.threshold
> some number

对于其他节点(对于同一模型),我们(正确)参见

print(tree.root_node)

Node ID 0 
Left child node ID = 1 Right child node ID = 2 
Splits on column some_categorical 
Split threshold < 2562.5 to the left node, >= 2562.5 to the right node 
NA values go to the LEFT

最初,我以为是因为在H2O中内部如何表示分类值

  

枚举或枚举:保留数据集不变,内部将字符串映射到   整数,然后使用这些整数进行拆分-通过序数   nbins_cats太小而无法解析所有级别或通过   位组可以完美地进行分组拆分。每个类别都是单独的   类别;其名称(或数字)无关。例如,   字符串被映射为Enum的整数,您可以拆分{0,1,2,3,4,   5}分别为{0,4,5}和{1,2,3}。

,但是看看信息输出显示的阈值大于阈值并且没有用于确定左右方向的电平的事实,您会发现这里还有其他问题。

在训练模型之前检查pandas到H2OFrame转换中使用的tree.root_node.features > some_other_categorical tree.root_node.levels > ['cat1', ..., 'catn'] root_node.threshold > na 映射并打印类型,我们可以看到将适当的类型设置为column_types,因此现在看到的输出令人困惑。任何人都知道可以在这里完成任何其他调试步骤或会发生什么情况?

1 个答案:

答案 0 :(得分:0)

这不是算法中的错误(拆分仍然正确),而是H2O-3在MOJO Tree可视化工具和tree API中表示拆分的方式。我创建了一个JIRA票证,您可以跟踪here(或添加到JIRA票证),这将确保MOJO Tree Visualizer和Tree API拆分的混乱程度降低(即使用数字拆分或显示类别级别列表)两者)。您看到的数字拆分对应于我们进行分类拆分的内部方法。