本文整理汇总了Golang中github.com/ajtulloch/decisiontrees/protobufs.TreeNode.GetLeafValue方法的典型用法代码示例。如果您正苦于以下问题:Golang TreeNode.GetLeafValue方法的具体用法?Golang TreeNode.GetLeafValue怎么用?Golang TreeNode.GetLeafValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ajtulloch/decisiontrees/protobufs.TreeNode
的用法示例。
在下文中一共展示了TreeNode.GetLeafValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printNode
func printNode(node *pb.TreeNode, c *codeWriter) {
if node.GetLeft() == nil && node.GetRight() == nil {
c.WriteString(fmt.Sprintf("return %v;\n", node.GetLeafValue()))
return
}
c.WriteString(fmt.Sprintf("if (%v(f[%v] < %v)) {\n", getAnnotation(node), node.GetFeature(), node.GetSplitValue()))
{
c.indentLevel++
printNode(node.GetLeft(), c)
c.indentLevel--
}
c.WriteString("} else {\n")
{
c.indentLevel++
printNode(node.GetRight(), c)
c.indentLevel--
}
c.WriteString("}\n")
}
示例2: flattenTree
func flattenTree(f *fastTreeEvaluator, current *pb.TreeNode, currentIndex int) {
glog.Infof("Flattening tree at index %v", currentIndex)
if isLeaf(current) {
f.nodes[currentIndex] = flatNode{
value: current.GetLeafValue(),
feature: leafFeatureID,
}
return
}
// append child nodes
// since we push on N + 2 elements, we want index N + 1, hence len(f.nodes)
leftChild := len(f.nodes)
f.nodes = append(f.nodes, flatNode{}, flatNode{})
f.nodes[currentIndex] = flatNode{
value: current.GetSplitValue(),
feature: current.GetFeature(),
leftChild: leftChild,
}
flattenTree(f, current.GetLeft(), leftChild)
flattenTree(f, current.GetRight(), leftChild+1)
}