/// <summary> /// перебор дерева по веткам /// </summary> /// <param name="D_Node"></param> /// <param name="D_B_N_C"></param> /// <param name="l"></param> public void recursion(DecisionNode D_Node, DecisionBranchNodeCollection D_B_N_C, int l) { int j; if (D_B_N_C != null) { for (j = 0; j < D_B_N_C.Count; j++) { dinosaurs.Add(D_B_N_C[j].ToString()); str.AppendLine(D_B_N_C[j].ToString()); recursion(D_B_N_C[j].Parent, D_B_N_C[j].Branches, j); } dinosaurs.Add("E"); dinosaurs.Add(D_Node.ToString()); str.AppendLine("E"); str.AppendLine(D_Node.ToString()); } str.AppendLine(D_Node.Branches[l].Output.ToString()); dinosaurs.Add(D_Node.Branches[l].Output.ToString()); dinosaurs.Add("WER"); str.AppendLine("WER"); dinosaurs.Add(D_Node.ToString()); str.AppendLine(D_Node.ToString()); }
private TreeNode convert(DecisionNode node) { TreeNode treeNode = new TreeNode(node.ToString()); if (node.IsLeaf) { treeNode.Nodes.Add(new TreeNode(node.Output.ToString())); } else { foreach (var child in node.Branches) treeNode.Nodes.Add(convert(child)); } return treeNode; }
private TreeNode convert(DecisionNode node) { TreeNode treeNode = (codebook == null) ? new TreeNode(node.ToString()) : new TreeNode(node.ToString(codebook)); if (!node.IsLeaf) { foreach (var child in node.Branches) treeNode.Nodes.Add(convert(child)); return treeNode; } if (codebook == null || !node.Output.HasValue) { treeNode.Nodes.Add(new TreeNode(node.Output.ToString())); return treeNode; } int index = node.Parent.Branches.AttributeIndex; var attrib = treeSource.Attributes[index]; if (attrib.Nature != DecisionVariableKind.Discrete) { treeNode.Nodes.Add(new TreeNode(node.Output.ToString())); return treeNode; } string value = codebook.Translate(attrib.Name, node.Output.Value); treeNode.Nodes.Add(new TreeNode(value)); return treeNode; }
// Regress tree private TreeNode convert(DecisionNode node) { string attributeName; string attributeValue; TreeNode treeNode; // Add root if (node.IsRoot) { treeNode = new TreeNode(node.ToString()); } else { attributeName = node.Owner.Attributes[node.Parent.Branches.AttributeIndex].Name; attributeValue = this.codification.Translate(attributeName, Convert.ToInt32(node.Value)); // Create new treeNode to TreeView treeNode = new TreeNode(attributeName + "=" + attributeValue); } // If node is leaf if (node.IsLeaf) { // If node has value add classifier value if (node.Output.HasValue) { attributeName = TableMetaData.ClassAttribute; attributeValue = this.codification.Translate(attributeName, Convert.ToInt32(node.Output)); treeNode.Nodes.Add(new TreeNode(attributeValue)); } // Add "" else { treeNode.Nodes.Add(new TreeNode(node.Output.ToString())); } } // Regress all child nodes else { foreach (var child in node.Branches) { treeNode.Nodes.Add(convert(child)); } } return treeNode; }