コード例 #1
0
        public override void BuildWithFallbackUsesFallbacks()
        {
            // Set all values in builder and build a configuration.
            var fallback = this._builder
                           .SetMaximumTreeDepth(13)
                           .SetFeaturesPerSplitRatio(0.37)
                           .SetMinimumInformationGain(0.04)
                           .SetMinimumSplitSize(56)
                           .SetRunParallel(false)
                           .SetSubSampleRatio(0.144)
                           .SetTreeCount(333)
                           .BuildWithFallback(null);

            // Create a new builder based on it and let it build a configuration.
            var config = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder()
                         .BuildWithFallback(fallback);

            // Check all values.
            Assert.Equal(
                fallback.MaximumTreeDepth,
                config.MaximumTreeDepth);
            Assert.Equal(
                fallback.FeaturesPerSplitRatio,
                config.FeaturesPerSplitRatio);
            Assert.Equal(
                fallback.MinimumInformationGain,
                config.MinimumInformationGain);
            Assert.Equal(fallback.RunParallel, config.RunParallel);
            Assert.Equal(fallback.SubSampleRatio, config.SubSampleRatio);
            Assert.Equal(fallback.TreeCount, config.TreeCount);
            Assert.Equal(
                fallback.MinimumSplitSize,
                config.MinimumSplitSize);
        }
コード例 #2
0
        public void ConstructorThrowsForNegativeFeaturesPerSplit()
        {
            var forestConfig = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder().SetTreeCount(1)
                               .SetRunParallel(false).BuildWithFallback(null);

            Assert.Throws <ArgumentOutOfRangeException>(() => new GenomePredictionRandomForest <ReuseOldTreesStrategy>(forestConfig, -1));
        }
コード例 #3
0
        public void TestMatrixShouldNotBeNull()
        {
            var forestConfig = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder().SetTreeCount(1)
                               .SetRunParallel(false).BuildWithFallback(null);
            var forest = new GenomePredictionRandomForest <ReuseOldTreesStrategy>(forestConfig, 0);

            Assert.Throws <NullReferenceException>(() => forest.Learn(null, new double[0], new int[0]));
        }
コード例 #4
0
        public void IsTechnicallyCompatibleReturnsFalseForDifferentTreeCount()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder()
                                .SetTreeCount(defaultConfig.TreeCount + 1)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckTechnicalIncompatibility(defaultConfig, otherConfig);
        }
コード例 #5
0
        public void IsCompatibleReturnsFalseForDifferentSubSampleRatio()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder()
                                .SetSubSampleRatio(defaultConfig.SubSampleRatio + 0.1)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig);
        }
コード例 #6
0
        public void IsCompatibleReturnsFalseForDifferentRunParallelFlag()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder()
                                .SetRunParallel(!defaultConfig.RunParallel)
                                .BuildWithFallback(defaultConfig);

            ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig);
        }
コード例 #7
0
        public void IsTechnicallyCompatibleReturnsTrueForSameParameters()
        {
            var defaultConfig = this._builder.BuildWithFallback(null);
            var otherConfig   = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder()
                                .BuildWithFallback(defaultConfig);

            // Check those two configuration are compatible.
            Assert.True(
                defaultConfig.IsTechnicallyCompatible(otherConfig),
                "Configurations should be technically compatible.");
            Assert.Equal(
                defaultConfig.IsTechnicallyCompatible(otherConfig),
                otherConfig.IsTechnicallyCompatible(defaultConfig));
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenomePredictionRandomForestConfigTest"/> class.
 /// </summary>
 public GenomePredictionRandomForestConfigTest()
 {
     this._builder =
         new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder();
 }