Exemple #1
0
        public void OptionBuilder_should_work_with_random_sweeper()
        {
            var context       = new MLContext();
            var builder       = new TestOptionBuilderWithSweepableAttributeOnly();
            var maximum       = 10;
            var sweeperOption = new UniformRandomSweeper.Option();

            var randomSweeper = new UniformRandomSweeper(sweeperOption);

            foreach (var sweeperOutput in randomSweeper.ProposeSweeps(builder, maximum))
            {
                maximum -= 1;
                var option = builder.BuildFromParameters(sweeperOutput);
                option.LongOption
                .Should()
                .BeLessOrEqualTo(100)
                .And
                .BeGreaterOrEqualTo(0);

                option.FloatOption
                .Should()
                .BeLessOrEqualTo(100f)
                .And
                .BeGreaterOrEqualTo(0f);

                option.StringOption
                .Should()
                .BeOneOf(new string[] { "str1", "str2", "str3", "str4" });

                maximum.Should().BeGreaterThan(-2);
            }
        }
        public UniformRandomSweeper CreateUniformRandomSweeper(int retry = 10)
        {
            var option = new UniformRandomSweeper.Option()
            {
                Retry = retry,
            };

            return(new UniformRandomSweeper(option));
        }
        public GaussProcessSweeper(Option option)
        {
            this._option     = option;
            this._generated  = new HashSet <IDictionary <string, string> >();
            this._runHistory = new List <IRunResult>();
            var randomSweeperOption = new UniformRandomSweeper.Option()
            {
                Retry = option.Retry,
            };

            this._randomSweeper = new UniformRandomSweeper(randomSweeperOption);

            var gpOption = new GaussProcessRegressor.Options()
            {
                l     = option.L,
                sigma = option.Sigma,
                noise = option.Noise,
            };

            this._regressor = new GaussProcessRegressor(gpOption);
        }