本文整理汇总了Python中titus.genpy.PFAEngine.fromPmml方法的典型用法代码示例。如果您正苦于以下问题:Python PFAEngine.fromPmml方法的具体用法?Python PFAEngine.fromPmml怎么用?Python PFAEngine.fromPmml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类titus.genpy.PFAEngine
的用法示例。
在下文中一共展示了PFAEngine.fromPmml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSimpleTree
# 需要导入模块: from titus.genpy import PFAEngine [as 别名]
# 或者: from titus.genpy.PFAEngine import fromPmml [as 别名]
def testSimpleTree(self):
engine, = PFAEngine.fromPmml(
"""
<PMML version="4.2">
<Header copyright=""/>
<DataDictionary>
<DataField name="x" optype="continuous" dataType="double" />
<DataField name="y" optype="continuous" dataType="integer" />
<DataField name="z" optype="categorical" dataType="string" />
</DataDictionary>
<TreeModel functionName="categorical" splitCharacteristic="binarySplit">
<Node>
<True/>
<Node>
<SimplePredicate field="x" operator="lessThan" value="1"/>
<Node score="leaf-1">
<SimplePredicate field="z" operator="equal" value="hello"/>
</Node>
<Node score="leaf-2">
<SimplePredicate field="z" operator="notEqual" value="hello"/>
</Node>
</Node>
<Node>
<SimplePredicate field="x" operator="greaterOrEqual" value="1"/>
<Node score="leaf-3">
<SimplePredicate field="z" operator="equal" value="hello"/>
</Node>
<Node score="leaf-4">
<SimplePredicate field="z" operator="notEqual" value="hello"/>
</Node>
</Node>
</Node>
</TreeModel>
</PMML>
"""
)
self.assertEqual(engine.action({"x": 0.9, "y": 0, "z": "hello"}), "leaf-1")
self.assertEqual(engine.action({"x": 0.9, "y": 0, "z": "goodbye"}), "leaf-2")
self.assertEqual(engine.action({"x": 1.1, "y": 0, "z": "hello"}), "leaf-3")
self.assertEqual(engine.action({"x": 1.1, "y": 0, "z": "goodbye"}), "leaf-4")