我使用 Augustus 作为 PMML 模型消费者。我已经修改了添加两个数字的示例以包含一个 DefineFunction 元素,如下所示:
<PMML version="4.1" xmlns="http://www.dmg.org/PMML-4_1">
<Header/>
<DataDictionary>
<DataField name="x" dataType="double" optype="continuous"/>
<DataField name="y" dataType="double" optype="continuous"/>
</DataDictionary>
<TransformationDictionary>
<DefineFunction dataType="float" optype="continuous" name="add">
<ParameterField optype="continuous" name="first"></ParameterField>
<ParameterField optype="continuous" name="second"></ParameterField>
<Apply function="+" invalidValueTreatment="returnInvalid">
<FieldRef field="first"></FieldRef>
<FieldRef field="second"></FieldRef>
</Apply>
</DefineFunction>
<DerivedField name="z" dataType="double" optype="continuous">
<Apply function="add">
<FieldRef field="x"/>
<FieldRef field="y"/>
</Apply>
</DerivedField>
</TransformationDictionary>
</PMML>
我将此模型保存在一个文件中并尝试像这样运行它:
from resources import add_two_numbers_file # this is just the path to my model file
from augustus.strict import modelLoader
# Load model
with open(add_two_numbers_file, 'r') as model_file:
model_str = model_file.read()
model = modelLoader.loadXml(model_str)
# Run model
print model.calc({'x':[1,2,3],'y':[4,5,6]}).look()
但是,我收到一个错误:
AttributeError: 'DefineFunction' object has no attribute '_setupCalculate'
我正在使用最新的主干(修订版 794)并且能够毫无问题地运行未修改的示例(没有 DefineFunction)。Augustus 是否支持 DefineFunction?