示例#1
0
        public void ScoreInformationHistoryScoresGenerationInformationObjectsWithoutTestInstances()
        {
            var incumbent1 = new Genome();

            incumbent1.SetGene(ExtractIntegerValue.ParameterName, new Allele <int>(-2));
            var generationInformation = new GenerationInformation(0, TimeSpan.Zero, 0, typeof(int), new ImmutableGenome(incumbent1), "id");

            var scorer = new GenerationInformationScorer <InstanceSeedFile, IntegerResult>(
                this._generationEvaluationActor,
                this._resultStorageActor,
                this._runEvaluator);

            scorer.ScoreInformationHistory(
                new List <GenerationInformation> {
                generationInformation
            },
                trainingInstances: GenerationInformationScorerTest.CreateInstances(startSeed: 50, number: 4),
                testInstances: new List <InstanceSeedFile>());

            Assert.Equal(
                -103,
                generationInformation.IncumbentTrainingScore);
            Assert.Null(
                generationInformation.IncumbentTestScore);
        }
示例#2
0
        public void ScoreInformationHistoryThrowsForMissingHistory()
        {
            var scorer = new GenerationInformationScorer <InstanceSeedFile, IntegerResult>(
                this._generationEvaluationActor,
                this._resultStorageActor,
                this._runEvaluator);

            Assert.Throws <ArgumentNullException>(
                () => scorer.ScoreInformationHistory(
                    informationHistory: null,
                    trainingInstances: GenerationInformationScorerTest.CreateInstances(0, 1),
                    testInstances: GenerationInformationScorerTest.CreateInstances(0, 1)));
        }
        /// <summary>
        /// Completes the generation information history and exports it to file.
        /// </summary>
        public void CompleteAndExportGenerationHistory()
        {
            if (this._configuration.ScoreGenerationHistory &&
                this._runEvaluator is IMetricRunEvaluator <TResult> metricRunEvaluator)
            {
                var scorer = new GenerationInformationScorer <TInstance, TResult>(
                    this._genomeSorter,
                    this._targetRunResultStorage,
                    metricRunEvaluator);

                scorer.ScoreInformationHistory(this._informationHistory, this._trainingInstances, this._testInstances);
                RunStatisticTracker.ExportAverageIncumbentScores(this._informationHistory, this._configuration.EvaluationLimit);
            }

            RunStatisticTracker.ExportGenerationHistory(this._informationHistory);
        }
示例#4
0
        public void ScoreInformationHistoryThrowsForMissingTestInstancesSet()
        {
            var scorer = new GenerationInformationScorer <InstanceSeedFile, IntegerResult>(
                this._generationEvaluationActor,
                this._resultStorageActor,
                this._runEvaluator);

            var dummyInformation = new GenerationInformation(0, TimeSpan.Zero, 0, typeof(int), new ImmutableGenome(new Genome()), "id");

            Assert.Throws <ArgumentNullException>(
                () => scorer.ScoreInformationHistory(
                    informationHistory: new List <GenerationInformation> {
                dummyInformation
            },
                    trainingInstances: GenerationInformationScorerTest.CreateInstances(0, 1),
                    testInstances: null));
        }
示例#5
0
        public void ScoreInformationHistoryThrowsForEmptySetOfTrainingInstances()
        {
            var scorer = new GenerationInformationScorer <InstanceSeedFile, IntegerResult>(
                this._genomeSorter,
                this._resultStorageActor,
                this._runEvaluator);

            var dummyInformation = new GenerationInformation(0, 0, typeof(int), new ImmutableGenome(new Genome()));

            Assert.Throws <ArgumentOutOfRangeException>(
                () => scorer.ScoreInformationHistory(
                    informationHistory: new List <GenerationInformation> {
                dummyInformation
            },
                    trainingInstances: new List <InstanceSeedFile>(),
                    testInstances: GenerationInformationScorerTest.CreateInstances(0, 1)));
        }