Beispiel #1
0
        private static string GetDataFilePath(BuildConfig buildConfig)
        {
            var dir = string.IsNullOrWhiteSpace(buildConfig.DataDirectory) ? Directory.GetCurrentDirectory() : buildConfig.DataDirectory;

            var path = Path.Combine(dir, "master_dataset.txt");

            if (!File.Exists(path))
            {
                Console.WriteLine($"File data not exists : {path}");
            }

            return(path);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var buildConfig = BuildConfig.GetCurrent();

            PrintConfigValues(buildConfig);

            var dataFilePath = GetDataFilePath(buildConfig);

            var trainer = new TrainerForBinaryClassification(dataFilePath);

            var metrics = trainer.Evaluate();

            //  Ensure metrics are in a acceptable range
            if (metrics.F1Score < TrainerForBinaryClassification.Threshold)
            {
                throw new ApplicationException("F1Score is too low!");
            }

            var modelOutputPath = buildConfig.GetModelFile().FullName;

            if (!trainer.SaveModel(modelOutputPath))
            {
                throw new ApplicationException($"ML Model cannot be saved to this position: {modelOutputPath}");
            }

            var printableMetrics = trainer.ToTextStats(metrics);

            Console.WriteLine(printableMetrics);

            Console.WriteLine($"Model written to disk, location: {modelOutputPath}");

            var changeLogPath = buildConfig.GetReleaseInfoMarkdown().FullName;

            File.WriteAllText(changeLogPath, trainer.ToMarkDownStats(metrics));

            Console.WriteLine($"Markdown changeLog written to disk, location: {changeLogPath}");
        }