Пример #1
0
        public virtual void dumpDot(PrintWriter @out)
        {
            @out.write("digraph \"CART Tree\" {\n");
            @out.write("rankdir = LR\n");
            DecisionTree.Node[] array = this.cart;
            int num = array.Length;

            for (int i = 0; i < num; i++)
            {
                DecisionTree.Node node = array[i];
                @out.println(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" [ label=\"").append(Object.instancehelper_toString(node)).append("\", color=").append(this.dumpDotNodeColor(node)).append(", shape=").append(this.dumpDotNodeShape(node)).append(" ]\n").toString());
                if (node is DecisionTree.DecisionNode)
                {
                    DecisionTree.DecisionNode decisionNode = (DecisionTree.DecisionNode)node;
                    if (decisionNode.qtrue < this.cart.Length && this.cart[decisionNode.qtrue] != null)
                    {
                        @out.write(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" -> \"node").append(Object.instancehelper_hashCode(this.cart[decisionNode.qtrue])).append("\" [ label=TRUE ]\n").toString());
                    }
                    if (decisionNode.qfalse < this.cart.Length && this.cart[decisionNode.qfalse] != null)
                    {
                        @out.write(new StringBuilder().append("\t\"node").append(Object.instancehelper_hashCode(node)).append("\" -> \"node").append(Object.instancehelper_hashCode(this.cart[decisionNode.qfalse])).append("\" [ label=FALSE ]\n").toString());
                    }
                }
            }
            @out.write("}\n");
            @out.close();
        }
Пример #2
0
        public virtual object interpret(Item item)
        {
            int num = 0;

            while (!(this.cart[num] is DecisionTree.LeafNode))
            {
                DecisionTree.DecisionNode decisionNode = (DecisionTree.DecisionNode) this.cart[num];
                num = decisionNode.getNextNode(item);
            }
            DecisionTree.logger.fine(new StringBuilder().append("LEAF ").append(this.cart[num].getValue()).toString());
            return(((DecisionTree.LeafNode) this.cart[num]).getValue());
        }