Ejemplo n.º 1
0
        private static void RunData <T>(string filename) where T : Col, new()
        {
            var t = new Tbl(new List <Col>());

            t.Read(filename);
            var splitter = new Div2();

            splitter.Split <T>(t, 1, 0);

            Console.Out.WriteLine($"----- Data File: {filename} ------ ");
            PrintSplit(splitter, 0, t);
        }
Ejemplo n.º 2
0
        public void Split(Tbl table, int colToSplitOn, int otherColumn)
        {
            table.Cols[colToSplitOn].SortNaturally();
            before = table.Cols[colToSplitOn].Clone();
            var other = table.Cols[otherColumn];

            step = (int)Math.Pow(before.cells.Count, min);

            start   = before.cells.First();
            stop    = before.cells.Last();
            ranges  = new List <Col>();
            epsilon = ((Num)other).SD * cohen;
            SplitInternal(before, 1);
            //gain /= len(i._lst);
        }
Ejemplo n.º 3
0
        private void Train(Row row, List <Col> cols)
        {
            string goal = row.GetGoals().First().RawValue;

            if (!_classCounts.ContainsKey(goal))
            {
                List <Col> colsCopy = new List <Col>();
                foreach (var col in cols)
                {
                    colsCopy.Add(col.Clone());
                }
                _classCounts[goal] = new Tbl(colsCopy);
            }

            Tbl table = _classCounts[goal];

            table.AddRow(row);
        }
Ejemplo n.º 4
0
        private static void RunData(string filename)
        {
            var t = new Tbl(new List <Col>());

            t.AddPredictor(new ZeroR()
            {
                BootstrapMin = 3
            }, "ZeroR");
            t.AddPredictor(new NaiveBayes()
            {
                BootstrapMin = 4
            }, "NaiveBayes");
            t.Read(filename);
            var results = t.GetResults();

            Console.Out.WriteLine($"----- Data File: {filename} ------ ");
            foreach (var r in results)
            {
                Console.Out.WriteLine($"----- Learner: {r.Label} ------ ");
                Console.Out.WriteLine(r.ToString());
            }
        }
Ejemplo n.º 5
0
        private static void PrintSplit(Div2 splitter, int xColumn, Tbl t)
        {
            StringBuilder b = new StringBuilder();

            foreach (var y in splitter.ranges)
            {
                var indices = y.cells.Select(cell => cell.Index());
                Num xCol    = new Num(t.Cols[xColumn].Name);

                var myXFriends = t.Cols[xColumn].cells.Where(cell1 => indices.Contains(cell1.Index()));

                foreach (var xf in myXFriends)
                {
                    xCol.AddCell(xf);
                }

                xCol.ToTreeString(b, 3, "x");
                b.Append("  |  ");
                y.ToTreeString(b, 3, "y");
                b.AppendLine("");
            }
//            b.AppendLine($"{splitter.before.Variety()} {splitter.gain}");
            Console.Out.WriteLine(b.ToString());
        }