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); }
public void ConstructorThrowsForNegativeFeaturesPerSplit() { var forestConfig = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder().SetTreeCount(1) .SetRunParallel(false).BuildWithFallback(null); Assert.Throws <ArgumentOutOfRangeException>(() => new GenomePredictionRandomForest <ReuseOldTreesStrategy>(forestConfig, -1)); }
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])); }
public void IsTechnicallyCompatibleReturnsFalseForDifferentTreeCount() { var defaultConfig = this._builder.BuildWithFallback(null); var otherConfig = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder() .SetTreeCount(defaultConfig.TreeCount + 1) .BuildWithFallback(defaultConfig); ConfigurationBaseTest.CheckTechnicalIncompatibility(defaultConfig, otherConfig); }
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); }
public void IsCompatibleReturnsFalseForDifferentRunParallelFlag() { var defaultConfig = this._builder.BuildWithFallback(null); var otherConfig = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder() .SetRunParallel(!defaultConfig.RunParallel) .BuildWithFallback(defaultConfig); ConfigurationBaseTest.CheckIncompatibility(defaultConfig, otherConfig); }
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)); }
/// <summary> /// Initializes a new instance of the <see cref="GenomePredictionRandomForestConfigTest"/> class. /// </summary> public GenomePredictionRandomForestConfigTest() { this._builder = new GenomePredictionRandomForestConfig.GenomePredictionRandomForestConfigBuilder(); }