예제 #1
0
파일: Program.cs 프로젝트: darko-i/mets_ann
        private static void LogEPV(ExperimentPredictiveValues ePV)
        {
            Console.Out.WriteLine("================================");

            Console.Out.WriteLine($"ANN PPV LEARN PPV:    {ePV.AnnPpvLearnPPV}");
            Console.Out.WriteLine($"ANN PPV LEARN NPV:    {ePV.AnnPpvLearnNPV}");
            Console.Out.WriteLine($"ANN PPV VALIDATE PPV: {ePV.AnnPpvValidatePPV}");
            Console.Out.WriteLine($"ANN PPV VALIDATE NPV: {ePV.AnnPpvValidateNPV}");
            Console.Out.WriteLine($"ANN PPV TEST PPV:     {ePV.AnnPpvTestPPV}");
            Console.Out.WriteLine($"ANN PPV TEST NPV:     {ePV.AnnPpvTestNPV}");

            Console.Out.WriteLine($"ANN NPV LEARN PPV:    {ePV.AnnNpvLearnPPV}");
            Console.Out.WriteLine($"ANN NPV LEARN NPV:    {ePV.AnnNpvLearnNPV}");
            Console.Out.WriteLine($"ANN NPV VALIDATE PPV: {ePV.AnnNpvValidatePPV}");
            Console.Out.WriteLine($"ANN NPV VALIDATE NPV: {ePV.AnnNpvValidateNPV}");
            Console.Out.WriteLine($"ANN NPV TEST PPV:     {ePV.AnnNpvTestPPV}");
            Console.Out.WriteLine($"ANN NPV TEST NPV:     {ePV.AnnNpvTestNPV}");

            Console.Out.WriteLine("================================");
        }
예제 #2
0
파일: Program.cs 프로젝트: darko-i/mets_ann
        private static Experiment3Output Experiment3(int neuronCount, decimal minAnnPPV, decimal minAnnNPV, int treeCount, decimal minForestPPV, decimal minForestNPV)
        {
            var result = new Experiment3Output();

            result.NeuronCount = neuronCount;

            var metsRecords = LoadDataRecords(TRAINING_DATA_FILE, 0);

            DateTime et = DateTime.Now;

            var currentMinPPV = 0m;
            var currentMinNPV = 0m;

            Data data = null;

            var learningData = new List<AnnLearningRecord>();
            var annPV = new AlgoritamPredictiveValues();
            var forestPV = new AlgoritamPredictiveValues();

            while (currentMinPPV < minAnnPPV || currentMinNPV < minAnnNPV || currentMinPPV <= currentMinNPV || currentMinPPV < minForestPPV || currentMinNPV < minForestNPV)
            {
                var es = DateTime.Now;

                data = CreateData(metsRecords, 0.8, 0.1);

                result.Means = data.Means;
                result.StandardDeviations = data.StandardDeviations;

                Console.Out.WriteLine("================================");
                Console.Out.WriteLine($"    ANN PPV, NC:{neuronCount}");
                Console.Out.WriteLine("================================");

                learningData.Clear();
                annPV = Ann(data, neuronCount, learningData, out var ann);
                currentMinPPV = annPV.TestPPV;
                currentMinNPV = annPV.TestNPV;

                result.Ann = ann;

                LogAPV(annPV);

                LogMessage($"Experiment time: {DateTime.Now - es}, total time {DateTime.Now - et}");
            }

                var experimentPV = new ExperimentPredictiveValues()
                {
                    AnnPpvLearnNPV = annPV.LearnNPV,
                    AnnPpvLearnPPV = annPV.LearnPPV,
                    AnnPpvValidateNPV = annPV.ValidateNPV,
                    AnnPpvValidatePPV = annPV.ValidatePPV,
                    AnnPpvTestNPV = annPV.TestNPV,
                    AnnPpvTestPPV = annPV.TestPPV,
                };

            using (var tw = File.CreateText($"d:\\mets_experiment_3_{neuronCount}_{DateTime.Now:yyyy_MM_dd_hh_mm}_rndfrst.csv"))
            {
                var csv = new CsvHelper.CsvWriter(tw);
                csv.WriteHeader<AnnLearningRecord>();
                csv.NextRecord();
                csv.WriteRecords(learningData);
            }

            using (var tw = File.CreateText($"d:\\mets_experiment_3_PV_{neuronCount}_{DateTime.Now:yyyy_MM_dd_hh_mm}_rndfrst.csv"))
            {
                var csv = new CsvHelper.CsvWriter(tw);
                csv.WriteHeader<ExperimentPredictiveValues>();
                csv.NextRecord();
                csv.WriteRecords(new ExperimentPredictiveValues[] { experimentPV });
            }

            return result;
        }
예제 #3
0
파일: Program.cs 프로젝트: darko-i/mets_ann
        private static void Experiment2(int neuronCountPPV, int neuronCountNPV, int repeats)
        {
            var metsRecords = LoadDataRecords(TRAINING_DATA_FILE, 0);

            var results = new List<ExperimentPredictiveValues>();

            DateTime et = DateTime.Now;

            for (int i = 0; i < repeats; i++)
            {
                var es = DateTime.Now;

                var data = CreateData(metsRecords, 0.8, 0.1);

                Console.Out.WriteLine("================================");
                Console.Out.WriteLine($"       EXPERIMENT #{i:000}");
                Console.Out.WriteLine("================================");
                Console.Out.WriteLine();

                Console.Out.WriteLine("================================");
                Console.Out.WriteLine($"    ANN PPV, NC:{neuronCountPPV}");
                Console.Out.WriteLine("================================");

                var ann_PPV_PV = Ann(data, neuronCountPPV, null, out var ann);
                LogAPV(ann_PPV_PV);

                var ann_NPV_PV = new AlgoritamPredictiveValues();
                if (neuronCountNPV != neuronCountPPV)
                {
                    Console.Out.WriteLine("================================");
                    Console.Out.WriteLine($"     ANN NPV, NC:{neuronCountNPV}");
                    Console.Out.WriteLine("================================");

                    ann_NPV_PV = Ann(data, neuronCountNPV, null, out ann);
                    LogAPV(ann_NPV_PV);
                }

                var experimentPV = new ExperimentPredictiveValues()
                {
                    AnnPpvLearnNPV = ann_PPV_PV.LearnNPV,
                    AnnPpvLearnPPV = ann_PPV_PV.LearnPPV,
                    AnnPpvLearnSENS = ann_PPV_PV.LearnSENS,
                    AnnPpvLearnSPEC = ann_PPV_PV.LearnSPEC,
                    AnnPpvValidateNPV = ann_PPV_PV.ValidateNPV,
                    AnnPpvValidatePPV = ann_PPV_PV.ValidatePPV,
                    AnnPpvValidateSENS = ann_PPV_PV.ValidateSENS,
                    AnnPpvValidateSPEC = ann_PPV_PV.ValidateSPEC,
                    AnnPpvTestNPV = ann_PPV_PV.TestNPV,
                    AnnPpvTestPPV = ann_PPV_PV.TestPPV,
                    AnnPpvTestSENS = ann_PPV_PV.TestSENS,
                    AnnPpvTestSPEC = ann_PPV_PV.TestSPEC,

                    AnnNpvLearnNPV = ann_NPV_PV.LearnNPV,
                    AnnNpvLearnPPV = ann_NPV_PV.LearnPPV,
                    AnnNpvLearnSENS = ann_NPV_PV.LearnSENS,
                    AnnNpvLearnSPEC = ann_NPV_PV.LearnSPEC,
                    AnnNpvValidateNPV = ann_NPV_PV.ValidateNPV,
                    AnnNpvValidatePPV = ann_NPV_PV.ValidatePPV,
                    AnnNpvValidateSENS = ann_NPV_PV.ValidateSENS,
                    AnnNpvValidateSPEC = ann_NPV_PV.ValidateSPEC,
                    AnnNpvTestNPV = ann_NPV_PV.TestNPV,
                    AnnNpvTestPPV = ann_NPV_PV.TestPPV,
                    AnnNpvTestSENS = ann_NPV_PV.TestSENS,
                    AnnNpvTestSPEC = ann_NPV_PV.TestSPEC,
                };

                LogEPV(experimentPV);

                results.Add(experimentPV);

                LogMessage($"Experiment time: {DateTime.Now - es}, total time {DateTime.Now - et}");
            }

            LogAvgEPV(results);

            using (var tw = File.CreateText($"d:\\mets_experiment_2_{neuronCountPPV}_{neuronCountNPV}_R{repeats}{DateTime.Now:yyyy_MM_dd_hh_mm}.csv"))
            {
                var csv = new CsvHelper.CsvWriter(tw);
                csv.WriteHeader<ExperimentPredictiveValues>();
                csv.NextRecord();
                csv.WriteRecords(results);
            }
        }