Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Learn" /> class.
        /// </summary>
        /// <param name="tree">The tree.</param>
        public Learn(Tree tree)
        {
            this.tree = tree;
            this.attributes = new bool[tree.InputCount];
            this.inputRanges = new IntRange[tree.InputCount];
            this.outputClasses = tree.OutputClasses;
            for (int i = 0; i < inputRanges.Length; i++)
                inputRanges[i] = tree.Attributes[i].Range.ToIntRange(false);

        }
Exemple #2
0
        /// <summary>
        /// Learns the tree.
        /// </summary>
        public void LearnTree()
        {
            tree = new Tree(attributes, classCount);
            Learn Learn = new Learn(tree);
            int[][] inputs = dataTable.ToIntArray("buying", "maint", "doors", "persons", "lug_boot", "safety");  // podajemy dla jakich atrybutów będziemy uczyć nasze drzewo
            int[] outputs = dataTable.ToIntArray("decision").GetColumn(0);  // Wartość decyzji
            double[][] dinputs = new double[inputs.Length][];
            for (int i = 0; i < inputs.Length; i++)
            {
                dinputs[i] = new double[inputs[i].Length];
                for (int j = 0; j < inputs[i].Length; j++)
                {
                    dinputs[i][j] = (double)inputs[i][j];
                }
            }

            Learn.Run(dinputs, outputs);
        }