8 instantiations of Parameter
Microsoft.ML.SearchSpace (8)
Parameter.cs (8)
86return new Parameter(value, ParameterType.Number); 95return new Parameter(value, ParameterType.Number); 104return new Parameter(value, ParameterType.Integer); 113return new Parameter(value, ParameterType.Integer); 122return new Parameter(value, ParameterType.String); 131return new Parameter(value, ParameterType.Bool); 155return new Parameter(values, ParameterType.Array); 221var parameter = new Parameter(new Dictionary<string, Parameter>(), ParameterType.Object);
323 references to Parameter
Microsoft.ML.AutoML (92)
API\AutoCatalog.cs (1)
304return new SweepableEstimator((MLContext context, Parameter param) => factory(context, param.AsType<T>()), ss);
API\BinaryClassificationExperiment.cs (1)
384var parameter = settings.Parameter[AutoMLExperiment.PipelineSearchspaceName];
API\MulticlassClassificationExperiment.cs (1)
364var parameter = settings.Parameter[AutoMLExperiment.PipelineSearchspaceName];
API\RegressionExperiment.cs (1)
391var parameter = settings.Parameter[AutoMLExperiment.PipelineSearchspaceName];
AutoMLExperiment\AutoMLExperiment.cs (2)
246Parameter = Parameter.CreateNestedParameter(), 249var parameter = tuner.Propose(trialSettings);
AutoMLExperiment\IDatasetManager.cs (2)
75var trainTestSplitParameter = settings?.Parameter.ContainsKey(nameof(TrainValidateDatasetManager)) is true ? settings.Parameter[nameof(TrainValidateDatasetManager)] : null; 76if (trainTestSplitParameter is Parameter parameter)
AutoMLExperiment\Runner\SweepablePipelineRunner.cs (1)
39var parameter = settings.Parameter[AutoMLExperiment.PipelineSearchspaceName];
AutoMLExperiment\TrialSettings.cs (1)
33public Parameter Parameter { get; set; }
SweepableEstimator\Converter\SweepableEstimatorConverter.cs (2)
20var parameter = jsonObject["parameter"].GetValue<Parameter>();
SweepableEstimator\Converter\SweepableEstimatorPipelineConverter.cs (3)
18var parameter = jNode["parameter"].GetValue<Parameter>(); 27var parameter = value.Parameter;
SweepableEstimator\Estimator.cs (2)
14Parameter = Parameter.CreateNestedParameter(); 26public Parameter Parameter { get; set; }
SweepableEstimator\ISweepable.cs (1)
20public T BuildFromOption(MLContext context, Parameter parameter);
SweepableEstimator\SweepableEstimator.cs (5)
19private readonly Func<MLContext, Parameter, IEstimator<ITransformer>> _factory; 21public SweepableEstimator(Func<MLContext, Parameter, IEstimator<ITransformer>> factory, SearchSpace.SearchSpace ss) 43public virtual IEstimator<ITransformer> BuildFromOption(MLContext context, Parameter param) 68set => base.Parameter = Parameter.FromObject(value); 71public override IEstimator<ITransformer> BuildFromOption(MLContext context, Parameter param)
SweepableEstimator\SweepableEstimatorPipeline.cs (5)
21Parameter = Parameter.CreateNestedParameter(); 27Parameter = Parameter.CreateNestedParameter(); 36internal SweepableEstimatorPipeline(IEnumerable<SweepableEstimator> estimators, Parameter parameter) 68public Parameter Parameter { get; set; } 75public EstimatorChain<ITransformer> BuildTrainingPipeline(MLContext context, Parameter parameter)
SweepableEstimator\SweepablePipeline.cs (9)
47public Parameter CurrentParameter 51var parameter = Parameter.CreateNestedParameter(); 52var kvPairs = _estimators.Select((e, i) => new KeyValuePair<string, Parameter>(i.ToString(), e.Value.Parameter)); 61parameter[SchemaOption] = Parameter.FromString(_currentSchema); 84public EstimatorChain<ITransformer> BuildFromOption(MLContext context, Parameter parameter) 95var param = parameter[key]; 151public string ToString(Parameter parameter) 153if (parameter.TryGetValue(AutoMLExperiment.PipelineSearchspaceName, out var pipelineParameter))
Tuner\AutoZeroTuner.cs (6)
79public Parameter Propose(TrialSettings settings) 97var parameter = pipeline.SearchSpace.SampleFromFeatureSpace(pipeline.SearchSpace.Default); 102parameter[trainerEstimatorName]["LabelColumnName"] = Parameter.FromString(label); 103parameter[trainerEstimatorName]["FeatureColumnName"] = Parameter.FromString(feature); 128public Parameter TrainerParameter { get; set; } 139public Parameter CustomDimensionsParameter { get; set; }
Tuner\CostFrugalTuner.cs (5)
31public CostFrugalTuner(SearchSpace.SearchSpace searchSpace, Parameter initValue = null, IEnumerable<TrialResult> trialResults = null, int? seed = null) 53public Parameter Propose(TrialSettings settings) 56Parameter param; 72public Parameter BestConfig { get; set; } 77var parameter = result.TrialSettings.Parameter;
Tuner\EciCfoTuner.cs (3)
22private readonly Parameter _defaultParameter; 49public Parameter Propose(TrialSettings settings) 54var parameter = tuner.Propose(settings);
Tuner\Flow2.cs (8)
25private readonly Parameter _initConfig; 31private Parameter _bestConfig; 40public Flow2(SearchSpace.SearchSpace searchSpace, Parameter initValue = null, bool minimizeMode = true, double convergeSpeed = 1.5, RandomNumberGenerator rng = null) 66public Parameter BestConfig 71public SearchThread CreateSearchThread(Parameter config, double metric, double cost) 79public Parameter Suggest(int trialId) 96var config = _searchSpace.SampleFromFeatureSpace(move); 100public void ReceiveTrialResult(Parameter parameter, double metric, double cost)
Tuner\GridSearchTuner.cs (3)
13private IEnumerator<Parameter> _enumerator; 25public Parameter Propose(TrialSettings settings) 34var res = _enumerator.Current;
Tuner\ITuner.cs (1)
11Parameter Propose(TrialSettings settings);
Tuner\RandomSearchTuner.cs (1)
29public Parameter Propose(TrialSettings settings)
Tuner\SearchThread.cs (2)
40public void OnTrialComplete(Parameter parameter, double metric, double cost) 64public Parameter Suggest(int trialId)
Tuner\SmacTuner.cs (24)
28private Queue<Parameter> _candidates; 76_candidates = new Queue<Parameter>(); 95public Parameter Propose(TrialSettings settings) 107_candidates = new Queue<Parameter>(GenerateCandidateConfigurations(_fitModelEveryNTrials, _histories, model)); 115internal Queue<Parameter> Candidates => _candidates; 169private Parameter[] GenerateCandidateConfigurations(int numOfCandidates, IEnumerable<TrialResult> previousRuns, FastForestRegressionModelParameters forest) 192private Parameter[] GreedyPlusRandomSearch(IEnumerable<Parameter> parents, FastForestRegressionModelParameters forest, int numOfCandidates) 196var configurations = new HashSet<Tuple<double, Parameter>>(); 199foreach (var c in parents) 207var randomConfigurations = randomParameters.Select(parameter => new Tuple<double, Parameter>(EvaluateConfigurationsByEI(forest, bestLoss, parameter), parameter)); 210var comparer = Parameter.FromInt(0); 211var retainedConfigs = new HashSet<Parameter>(orderedConfigurations.Select(x => x.Item2), comparer); 229private Tuple<double, Parameter> LocalSearch(Parameter startParameter, FastForestRegressionModelParameters forest, double bestLoss) 234var currentBestConfig = startParameter; 238Parameter[] neighborhood = GetOneMutationNeighborhood(currentBestConfig); 250return new Tuple<double, Parameter>(currentBestEI, currentBestConfig); 258private Parameter[] GetOneMutationNeighborhood(Parameter currentBestConfig) 260var neighborhood = new List<Parameter>(); 306private double EvaluateConfigurationsByEI(FastForestRegressionModelParameters forest, double bestVal, Parameter parameter) 319private double[] GetForestRegressionLeafValues(FastForestRegressionModelParameters forest, Parameter parameter)
Utils\BestResultUtil.cs (2)
102var parameter = result.TrialSettings.Parameter; 114var parameter = result.TrialSettings.Parameter;
Microsoft.ML.AutoML.Interactive (1)
AutoMLMonitorKernelExtension.cs (1)
25Formatter.Register<Parameter>((parameter) => JsonSerializer.Serialize(parameter, new JsonSerializerOptions() { WriteIndented = true, }));
Microsoft.ML.AutoML.Samples (6)
Sweepable\ParameterExample.cs (6)
16var intParam = Parameter.FromInt(10); 17var doubleParam = Parameter.FromDouble(20); 18var boolParam = Parameter.FromBool(false);
Microsoft.ML.AutoML.Tests (25)
GridSearchTunerTests.cs (1)
39var parameters = new List<Parameter>();
TrainValidaionDatasetManagerTest.cs (4)
39var parameter = Parameter.CreateNestedParameter(); 40parameter[nameof(TrainValidateDatasetManager)] = Parameter.CreateNestedParameter(); 41parameter[nameof(TrainValidateDatasetManager)][trainValidationDatasetManager.SubSamplingKey] = Parameter.FromDouble(0.3);
TrialResultManagerTest.cs (1)
42var parameter = tuner.Propose(trialSettings);
TunerTests.cs (19)
35var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues)); 52var param = tuner.Propose(trialSettings); 83var param = tuner.Propose(trialSettings); 109var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues), seed: seed); 118var param = cfo.Propose(settings); 135var newCfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues), history.Take(99), seed); 138var nextParameterFromNewCfo = newCfo.Propose(trialSettings); 154var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues)); 184Parameter = Parameter.CreateNestedParameter(), 186var parameter = tuner.Propose(trialSetting); 219Parameter = Parameter.CreateNestedParameter(), 221var parameter = tuner.Propose(trialSetting); 240var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues)); 262var param = tuner.Propose(trialSettings); 295var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues)); 317var param = tuner.Propose(trialSettings); 344var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues)); 363var param = tuner.Propose(trialSettings); 392var cfo = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues));
Microsoft.ML.Fairlearn (3)
AutoML\AutoMLExperimentExtension.cs (1)
62Parameter = Parameter.CreateNestedParameter(),
AutoML\TunerFactory.cs (1)
39public Parameter Propose(TrialSettings settings)
Reductions\GridSearchTrialRunner.cs (1)
57var lambdas = settings.Parameter["_lambda_search_space"];
Microsoft.ML.SearchSpace (156)
Converter\ParameterConverter.cs (13)
13internal class ParameterConverter : JsonConverter<Parameter> 15public override Parameter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 20var array = JsonSerializer.Deserialize<Dictionary<string, Parameter>>(ref reader, options).ToArray(); 21return Parameter.CreateNestedParameter(array); 23return Parameter.FromString(JsonSerializer.Deserialize<string>(ref reader, options)); 27return Parameter.FromLong(_long); 31return Parameter.FromInt(_int); 34return Parameter.FromDouble(JsonSerializer.Deserialize<double>(ref reader, options)); 36return Parameter.FromBool(true); 38return Parameter.FromBool(false); 40return default(Parameter); 48return Parameter.FromIEnumerable(list); 54public override void Write(Utf8JsonWriter writer, Parameter value, JsonSerializerOptions options)
Option\ChoiceOption.cs (7)
32Choices = distinctChoices.Select(o => Parameter.FromObject(o)).ToArray(); 45Default = MappingToFeatureSpace(Parameter.FromObject(defaultChoice)); 52public Parameter[] Choices { get; } 61public override double[] MappingToFeatureSpace(Parameter param) 71return _option.MappingToFeatureSpace(Parameter.FromInt(x)); 75public override Parameter SampleFromFeatureSpace(double[] values) 83var param = _option.SampleFromFeatureSpace(values);
Option\NestOption.cs (5)
49public override Parameter SampleFromFeatureSpace(double[] values) 51var param = Parameter.CreateNestedParameter(); 65public override double[] MappingToFeatureSpace(Parameter parameter) 71var input = parameter[key];
Option\OptionBase.cs (2)
23public abstract double[] MappingToFeatureSpace(Parameter value); 30public abstract Parameter SampleFromFeatureSpace(double[] values);
Option\UniformNumericOption.cs (16)
57public override double[] MappingToFeatureSpace(Parameter param) 76public override Parameter SampleFromFeatureSpace(double[] values) 86return Parameter.FromDouble(res); 90return Parameter.FromDouble((Min + (Max - Min) * value)); 112Default = MappingToFeatureSpace(Parameter.FromDouble(defaultValue.Value)); 134Default = MappingToFeatureSpace(Parameter.FromFloat(defaultValue.Value)); 139public override double[] MappingToFeatureSpace(Parameter param) 143return base.MappingToFeatureSpace(Parameter.FromDouble(doubleValue)); 147public override Parameter SampleFromFeatureSpace(double[] values) 151return Parameter.FromFloat(singleValue); 172Default = MappingToFeatureSpace(Parameter.FromInt(defaultValue.Value)); 177public override Parameter SampleFromFeatureSpace(double[] values) 179var param = base.SampleFromFeatureSpace(values); 182return Parameter.FromInt(intValue); 186public override double[] MappingToFeatureSpace(Parameter param) 190return base.MappingToFeatureSpace(Parameter.FromDouble(valueAsDouble));
Parameter.cs (91)
17/// Parameter type. This type is used to determine the type of <see cref="Parameter"/> and is associated to corresponded Json token when serializing/deserializing. 53/// <see cref="Parameter"/> is used to save sweeping result from tuner and is used to restore mlnet pipeline from sweepable pipeline. 63public sealed class Parameter : IDictionary<string, Parameter>, IEquatable<Parameter>, IEqualityComparer<Parameter> 81/// Create a <see cref="Parameter"/> from a <see cref="double"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Number"/>. 83/// <returns><see cref="Parameter"/></returns> 84public static Parameter FromDouble(double value) 90/// Create a <see cref="Parameter"/> from a <see cref="float"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Number"/>. 92/// <returns><see cref="Parameter"/></returns> 93public static Parameter FromFloat(float value) 99/// Create a <see cref="Parameter"/> from a <see cref="long"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Integer"/>. 101/// <returns><see cref="Parameter"/></returns> 102public static Parameter FromLong(long value) 108/// Create a <see cref="Parameter"/> from a <see cref="int"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Integer"/>. 110/// <returns><see cref="Parameter"/></returns> 111public static Parameter FromInt(int value) 117/// Create a <see cref="Parameter"/> from a <see cref="string"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.String"/>. 119/// <returns><see cref="Parameter"/></returns> 120public static Parameter FromString(string value) 126/// Create a <see cref="Parameter"/> from a <see cref="bool"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Bool"/>. 128/// <returns><see cref="Parameter"/></returns> 129public static Parameter FromBool(bool value) 135/// Create a <see cref="Parameter"/> from a <see cref="Enum"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.String"/>. 137/// <returns><see cref="Parameter"/></returns> 138public static Parameter FromEnum<T>(T value) where T : struct, Enum 140return Parameter.FromEnum(value, typeof(T)); 144/// Create a <see cref="Parameter"/> from a <see cref="IEnumerable"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Array"/>. 146/// <returns><see cref="Parameter"/></returns> 147public static Parameter FromIEnumerable<T>(IEnumerable<T> values) 150return Parameter.FromIEnumerable(values as IEnumerable); 153private static Parameter FromIEnumerable(IEnumerable values) 158private static Parameter FromEnum(Enum e, Type t) 160return Parameter.FromString(Enum.GetName(t, e)); 164/// Create a <see cref="Parameter"/> from an <see cref="object"/> value. The <see cref="ParameterType"/> will be <see cref="ParameterType.Object"/>. 166/// <returns><see cref="Parameter"/></returns> 167public static Parameter FromObject<T>(T value) where T : class 169return Parameter.FromObject(value, typeof(T)); 172private static Parameter FromObject(object value, Type type) 174var param = value switch 176int i => Parameter.FromInt(i), 177long l => Parameter.FromLong(l), 178double d => Parameter.FromDouble(d), 179float f => Parameter.FromFloat(f), 180string s => Parameter.FromString(s), 181bool b => Parameter.FromBool(b), 182IEnumerable vs => Parameter.FromIEnumerable(vs), 183Enum e => Parameter.FromEnum(e, e.GetType()), 193var parameter = Parameter.CreateNestedParameter(); 202var p = Parameter.FromObject(pValue, property.PropertyType); 216/// Create a <see cref="Parameter"/> from <paramref name="parameters"/>. The <see cref="ParameterType"/> will be <see cref="ParameterType.Object"/>. 218/// <returns><see cref="Parameter"/></returns> 219public static Parameter CreateNestedParameter(params KeyValuePair<string, Parameter>[] parameters) 221var parameter = new Parameter(new Dictionary<string, Parameter>(), ParameterType.Object); 233public int Count => ParameterType == ParameterType.Object ? (_value as Dictionary<string, Parameter>).Count : 1; 241return (_value as IDictionary<string, Parameter>)?.IsReadOnly ?? false; 250ICollection<Parameter> IDictionary<string, Parameter>.Values 255return (_value as IDictionary<string, Parameter>).Values; 265return (_value as IDictionary<string, Parameter>).Keys; 270public Parameter this[string key] 275return (_value as IDictionary<string, Parameter>)[key]; 281(_value as IDictionary<string, Parameter>)[key] = value; 306(_value as Dictionary<string, Parameter>).Clear(); 310public void Add(string key, Parameter value) 313(_value as Dictionary<string, Parameter>).Add(key, value); 317public bool TryGetValue(string key, out Parameter value) 320return (_value as Dictionary<string, Parameter>).TryGetValue(key, out value); 324public void Add(KeyValuePair<string, Parameter> item) 327(_value as Dictionary<string, Parameter>).Add(item.Key, item.Value); 331public bool Contains(KeyValuePair<string, Parameter> item) 334return (_value as Dictionary<string, Parameter>).Contains(item); 338public bool Remove(KeyValuePair<string, Parameter> item) 341return (_value as IDictionary<string, Parameter>).Remove(item); 345IEnumerator<KeyValuePair<string, Parameter>> IEnumerable<KeyValuePair<string, Parameter>>.GetEnumerator() 348return (_value as IDictionary<string, Parameter>).GetEnumerator(); 355return (_value as IDictionary<string, Parameter>).GetEnumerator(); 364public void CopyTo(KeyValuePair<string, Parameter>[] array, int arrayIndex) 367(_value as IDictionary<string, Parameter>).CopyTo(array, arrayIndex); 374return (_value as IDictionary<string, Parameter>).ContainsKey(key); 381return (_value as IDictionary<string, Parameter>).Remove(key); 385public bool Equals(Parameter other) 407/// Determines wether two <see cref="Parameter"/> objects have the same value. 412public bool Equals(Parameter x, Parameter y) 418public int GetHashCode(Parameter obj)
SearchSpace.cs (18)
30private readonly Parameter _defaultOption; 66protected SearchSpace(Type typeInfo, Parameter defaultOption = null) 109public override Parameter SampleFromFeatureSpace(double[] feature) 112var param = Parameter.CreateNestedParameter(); 119var value = option.SampleFromFeatureSpace(input); 133public override double[] MappingToFeatureSpace(Parameter parameter) 139var input = parameter[key]; 156var parameter = SampleFromFeatureSpace(featureSpace); 376private Parameter Update(Parameter left, Parameter right) 378var res = (left?.ParameterType, right?.ParameterType) switch 390res = Parameter.CreateNestedParameter(); 425: base(typeof(T), Parameter.FromObject(defaultOption)) 433var param = base.SampleFromFeatureSpace(feature); 442var param = Parameter.FromObject(input);
Tuner\DefaultValueTuner.cs (1)
19public Parameter Propose()
Tuner\GridSearchTuner.cs (1)
21public IEnumerable<Parameter> Propose()
Tuner\RandomTuner.cs (2)
31public Parameter Propose(SearchSpace searchSpace) 38public void Update(Parameter param, double metric, bool isMaximize)
Microsoft.ML.SearchSpace.Tests (40)
ChoiceOptionTest.cs (6)
44option.MappingToFeatureSpace(Parameter.FromString("a"))[0].Should().BeApproximately(0, 1e-5); 45option.MappingToFeatureSpace(Parameter.FromString("b"))[0].Should().BeApproximately(0.333333, 1e-5); 46option.MappingToFeatureSpace(Parameter.FromString("c"))[0].Should().BeApproximately(0.666666, 1e-5); 49var parameter = option.SampleFromFeatureSpace(new[] { 0.5 }); 61option.MappingToFeatureSpace(Parameter.FromString("b")).Should().BeEmpty(); 69var parameter = searchSpace.SampleFromFeatureSpace(new[] { 0.5 });
ParameterTest.cs (23)
38var parameter = Parameter.FromIEnumerable(array); 43parameter = JsonSerializer.Deserialize<Parameter>(json); 50var parameter = Parameter.FromInt(3); 56parameter = Parameter.FromDouble(3.1415926); 60parameter = Parameter.FromFloat(3.1415926F); 64parameter = Parameter.FromString("abc"); 68parameter = Parameter.FromBool(false); 72parameter = Parameter.FromIEnumerable(new[] { "a", "b", "c" }); 76parameter = Parameter.FromEnum(JsonTokenType.None); 80parameter = Parameter.FromLong(long.MaxValue); 88var parameter = Parameter.FromObject(b); 108var parameter = Parameter.FromObject(b); 112parameter = JsonSerializer.Deserialize<Parameter>(json); 131var parameter = ss.SampleFromFeatureSpace(new[] { 0.5 }); 145var paramB1 = Parameter.FromObject(b); 146var paramB2 = Parameter.FromObject(b); 151paramB2 = Parameter.FromObject(b);
SearchSpaceTest.cs (7)
137var param = ss.SampleFromFeatureSpace(new[] { 0.5 }); 228var parameter = searchSpace.SampleFromFeatureSpace(new double[] { 0, 0, 0, 0 }); 248var parameter = Parameter.CreateNestedParameter(); 249parameter["choice"] = Parameter.FromString("a"); 250parameter["int"] = Parameter.FromInt(0); 264var parameter = searchSpace.SampleFromFeatureSpace(new double[] { 0, 0.5, 0.5 });
UniformNumericOptionTests.cs (4)
47var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromInt(i * 10)); 65var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromInt(Convert.ToInt32(Math.Pow(2, i)))); 105var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromDouble(i * 10.0)); 116var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromDouble(Math.Pow(2, i)));