Beispiel #1
0
        protected override Framework.Core.Evaluation.Results.Results internalRun(Database <TInputRecord> inputDatabase)
        {
            //create database subsets
            TrainTestAndValidationDatabaseSubsetCreator <TInputRecord> ttvSubset =
                new Framework.Extensions.Standard.Database.Subsets.TrainTestAndValidationDatabaseSubsetCreator <TInputRecord>(
                    inputDatabase,
                    settings.ValidatorSamplesRatio,
                    settings.TrainTestSamplesRatio
                    );

            //template subset
            Database <TInputRecord> trainDbSubset      = ttvSubset.getDatabaseSubset(TrainTestAndValidationDatabaseSubsetCreator <TInputRecord> .TrainSubset);
            Database <TInputRecord> testDbSubset       = ttvSubset.getDatabaseSubset(TrainTestAndValidationDatabaseSubsetCreator <TInputRecord> .TestSubset);
            Database <TInputRecord> validationDbSubset = ttvSubset.getDatabaseSubset(TrainTestAndValidationDatabaseSubsetCreator <TInputRecord> .ValidationSubset);

            this.trainableObject.ProgressChangedEvent += new Framework.Core.ProgressChangedEventHandler(trainableObject_ProgressChangedEvent);

            Console.WriteLine("Training");

            this.trainableObject.train(trainDbSubset.getCollections());

            Console.WriteLine();
            Console.WriteLine("Training done");
            Console.WriteLine("-------------");
            Console.WriteLine("Testing");

            double error = this.trainableObject.test(testDbSubset.getCollections());

            Console.WriteLine();
            Console.WriteLine("Testing error is " + error);

            Console.WriteLine("-------------");

            Console.WriteLine("Validation start");

            Framework.Core.Evaluation.Results.Results r = base.internalRun(validationDbSubset);
            //Framework.Core.Evaluation.Results.Results r = base.internalRun(inputDatabase);


            Console.WriteLine("Validation done");

            return(r);
        }
Beispiel #2
0
        protected virtual BIO.Framework.Core.Evaluation.Results.Results internalRun(Database <TInputRecord> inputDatabase)
        {
            //create database subsets
            TemplateAndEvaluationDatabaseSubsetCreator <TInputRecord> templateTestSubset =
                new Framework.Extensions.Standard.Database.Subsets.TemplateAndEvaluationDatabaseSubsetCreator <TInputRecord>(
                    inputDatabase,
                    settings.TemplateSamples
                    );

            //template subset
            Database <TInputRecord> templateDbSubset = templateTestSubset.getDatabaseSubset(TemplateAndEvaluationDatabaseSubsetCreator <TInputRecord> .TemplateSubset);

            //debugging console output
            this.printDbOverview("Templates database subset", templateDbSubset.getCollections());


            //database for templates
            BIO.Framework.Core.Database.TemplateDatabase.TemplateDatabase templateDatabase = new BIO.Framework.Core.Database.TemplateDatabase.TemplateDatabase();
            //progress report event
            settings.getBlockEvaluator().ProgressChangedEvent += new Framework.Core.ProgressChangedEventHandler(evaluator_ProgressChangedEvent);
            //template extraction
            Console.WriteLine("Template extraction");
            settings.getBlockEvaluator().extractTemplates(
                templateDbSubset.getCollections(),
                templateDatabase
                );

            Console.WriteLine();
            Console.WriteLine("Template extraction done");

            Console.WriteLine();
            //test subset
            Database <TInputRecord> testDbSubset = templateTestSubset.getDatabaseSubset(TemplateAndEvaluationDatabaseSubsetCreator <TInputRecord> .EvaluationSubset);

            //debugging console output
            this.printDbOverview("Evaluation database subset", testDbSubset.getCollections());


            //templates are ready - now evaluate db
            Console.WriteLine("Algorithm evaluation");
            //where to store results
            BIO.Framework.Core.Evaluation.Results.Results results = new Framework.Core.Evaluation.Results.Results();
            //own evaluation
            settings.getBlockEvaluator().evaluateRecords(
                testDbSubset.getCollections(),
                templateDatabase,
                results);

            Console.WriteLine();
            Console.WriteLine("Algorithm evaluation done");

            //save results to file (xml|binary and plain|zipped)
            string             fileName    = "results.zip";
            ResultsPersistence persistence = new ResultsPersistence(new CompressedResultsPersistence <XmlResultsSerializer>());

            persistence.saveResults(results, fileName);
            Console.WriteLine("Results saved to " + fileName);

            //postprocess results
            List <IResultsVisualizer> postprocessors = new List <IResultsVisualizer>();

            //statistics
            postprocessors.Add(new BIO.Framework.Extensions.Standard.Evaluation.Results.Visualization.StatisticsSummaryResultsPostprocessor("summary.txt"));
            //genuine x impostor graph
            postprocessors.Add(new BIO.Framework.Extensions.ZedGraph.Evaluation.Results.Visualization.ZedGraphResultsGraphVisualizer("GenuineImpostor.png"));

            foreach (IResultsVisualizer pp in postprocessors)
            {
                pp.ProgressChangedEvent += new Framework.Core.ProgressChangedEventHandler(evaluator_ProgressChangedEvent);
                pp.postprocessResults(results);
            }

            Console.WriteLine();

            return(results);
        }