public static TreeStatistics CollectC50(string chunk50Path)
        {
            if (!File.Exists(chunk50Path))
            {
                return null;
            }

            string contents = File.ReadAllText(chunk50Path);

            var statistics = new TreeStatistics
            {
                Algorithm = "C5.0",
                DataSetSize = GetSize(contents),
                Errors = GetErrorsC50(contents)
            };

            if (statistics.DataSetSize == -1 || statistics.Errors == -1)
            {
                return null;
            }

            return statistics;
        }
        public static TreeStatistics CollectC45(string c45Path)
        {
            if (!File.Exists(c45Path))
            {
                return(null);
            }

            string contents = File.ReadAllText(c45Path);

            var statistics = new TreeStatistics
            {
                Algorithm   = "C4.5",
                DataSetSize = GetSize(contents),
                Errors      = GetErrorsC45(contents)
            };

            if (statistics.DataSetSize == -1 || statistics.Errors == -1)
            {
                return(null);
            }

            return(statistics);
        }
Beispiel #3
0
        private static void SaveData(StringBuilder builder, string treesPath, string period, int chunkNumber)
        {
            var c45File     = string.Format("Forex_{0}.C45.done", chunkNumber);
            var c50File     = string.Format("Forex_{0}.C50.done", chunkNumber);
            var chunk45Path = Path.Combine(treesPath, c45File);
            var chunk50Path = Path.Combine(treesPath, c50File);

            TreeStatistics c45Statistics = null;

            if (period != "21600")

            {
                c45Statistics = StatisticsCollector.CollectC45(chunk45Path);
                if (c45Statistics == null)
                {
                    return;
                }
                c45Statistics.ChunkNumber = chunkNumber;
            }

            var c50Statistics = StatisticsCollector.CollectC50(chunk50Path);

            if (c50Statistics == null)
            {
                return;
            }
            c50Statistics.ChunkNumber = chunkNumber;

            if (c45Statistics != null)
            {
                builder.AppendLine(string.Format("{0},{1},{2},{3}", c45Statistics.Algorithm, c45Statistics.DataSetSize,
                                                 c45Statistics.Errors, c45Statistics.ChunkNumber));
            }
            builder.AppendLine(string.Format("{0},{1},{2},{3}", c50Statistics.Algorithm, c50Statistics.DataSetSize,
                                             c50Statistics.Errors, c50Statistics.ChunkNumber));
        }