SearchSpace Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This class is used to represent a set of OptionBase, which can be either one of ChoiceOption, UniformNumericOption or another nested search space.
[System.Text.Json.Serialization.JsonConverter(typeof(Microsoft.ML.SearchSpace.Converter.SearchSpaceConverter))]
public class SearchSpace : Microsoft.ML.SearchSpace.Option.OptionBase, System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,Microsoft.ML.SearchSpace.Option.OptionBase>>, System.Collections.Generic.IDictionary<string,Microsoft.ML.SearchSpace.Option.OptionBase>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,Microsoft.ML.SearchSpace.Option.OptionBase>>
public class SearchSpace : Microsoft.ML.SearchSpace.Option.OptionBase, System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,Microsoft.ML.SearchSpace.Option.OptionBase>>, System.Collections.Generic.IDictionary<string,Microsoft.ML.SearchSpace.Option.OptionBase>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,Microsoft.ML.SearchSpace.Option.OptionBase>>
[<System.Text.Json.Serialization.JsonConverter(typeof(Microsoft.ML.SearchSpace.Converter.SearchSpaceConverter))>]
type SearchSpace = class
inherit OptionBase
interface IDictionary<string, OptionBase>
interface ICollection<KeyValuePair<string, OptionBase>>
interface seq<KeyValuePair<string, OptionBase>>
interface IEnumerable
type SearchSpace = class
inherit OptionBase
interface IDictionary<string, OptionBase>
interface ICollection<KeyValuePair<string, OptionBase>>
interface seq<KeyValuePair<string, OptionBase>>
interface IEnumerable
Public Class SearchSpace
Inherits OptionBase
Implements ICollection(Of KeyValuePair(Of String, OptionBase)), IDictionary(Of String, OptionBase), IEnumerable(Of KeyValuePair(Of String, OptionBase))
- Inheritance
- Derived
- Attributes
- Implements
-
ICollection<KeyValuePair<String,OptionBase>> ICollection<KeyValuePair<TKey,TValue>> IDictionary<String,OptionBase> IEnumerable<KeyValuePair<String,OptionBase>> IEnumerable<KeyValuePair<TKey,TValue>> IEnumerable<T> IEnumerable
Examples
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Text.Json;
using Microsoft.ML.SearchSpace;
using Microsoft.ML.SearchSpace.Option;
namespace Microsoft.ML.AutoML.Samples
{
public static class SearchSpaceExample
{
public static void Run()
{
// The following code shows how to create a SearchSpace for MyParameter.
var myParameterSearchSpace = new SearchSpace<MyParameter>();
// Equivalently, you can also create myParameterSearchSpace from scratch.
var myParameterSearchSpace2 = new SearchSpace.SearchSpace();
// numeric options
myParameterSearchSpace2["IntOption"] = new UniformIntOption(min: -10, max: 10, logBase: false, defaultValue: 0);
myParameterSearchSpace2["SingleOption"] = new UniformSingleOption(min: 1, max: 10, logBase: true, defaultValue: 1);
myParameterSearchSpace2["DoubleOption"] = new UniformDoubleOption(min: -10, max: 10, logBase: false, defaultValue: 0);
// choice options
myParameterSearchSpace2["BoolOption"] = new ChoiceOption(true, false);
myParameterSearchSpace2["StrOption"] = new ChoiceOption("a", "b", "c");
// nest options
var nestedSearchSpace = new SearchSpace.SearchSpace();
nestedSearchSpace["IntOption"] = new UniformIntOption(min: -10, max: 10, logBase: false, defaultValue: 0);
myParameterSearchSpace2["Nest"] = nestedSearchSpace;
// the two search space should be equal
Debug.Assert(myParameterSearchSpace.GetHashCode() == myParameterSearchSpace2.GetHashCode());
}
public class MyParameter
{
[Range((int)-10, 10, 0, false)]
public int IntOption { get; set; }
[Range(1f, 10f, 1f, true)]
public float SingleOption { get; set; }
[Range(-10, 10, false)]
public double DoubleOption { get; set; }
[BooleanChoice]
public bool BoolOption { get; set; }
[Choice("a", "b", "c")]
public string StrOption { get; set; }
[NestOption]
public NestParameter Nest { get; set; }
}
public class NestParameter
{
[Range((int)-10, 10, 0, false)]
public int IntOption { get; set; }
}
}
}
Constructors
SearchSpace() | Initializes a new instance of the Object class. |
SearchSpace(Type, Parameter) | System.Object.#ctor(System.Type,Microsoft.ML.SearchSpace.Parameter) |
Properties
Count | Gets the number of elements contained in the ICollection<T>. |
Default |
Gets the default value which is mapping to feature space (if exists). |
FeatureSpaceDim |
the dimension of feature space, which is equal to the output length of SampleFromFeatureSpace(Double[]). |
IsReadOnly | Gets a value indicating whether the ICollection<T> is read-only. |
Item[String] | Gets or sets the element with the specified key. |
Keys | Gets an ICollection<T> containing the keys of the IDictionary<TKey,TValue>. |
Step |
Gets the step of this option. The Step is used to determine the number of grid this option should be divided into. In ChoiceOption, it's always the length of Choices. And in UniformNumericOption, it's always [null]. And in SearchSpace, it's a combination of all Step in its options. |
Values | Gets an ICollection<T> containing the values in the IDictionary<TKey,TValue>. |
Methods
Add(KeyValuePair<String,OptionBase>) | Adds an item to the ICollection<T>. |
Add(String, OptionBase) | Adds an element with the provided key and value to the IDictionary<TKey,TValue>. |
Clear() | Removes all items from the ICollection<T>. |
Contains(KeyValuePair<String,OptionBase>) | Determines whether the ICollection<T> contains a specific value. |
ContainsKey(String) | Determines whether the IDictionary<TKey,TValue> contains an element with the specified key. |
CopyTo(KeyValuePair<String,OptionBase>[], Int32) | Copies the elements of the ICollection<T> to an Array, starting at a particular Array index. |
GetEnumerator() | Returns an enumerator that iterates through the collection. |
GetHashCode() | Serves as the default hash function. |
MappingToFeatureSpace(Parameter) |
mapping value to [0, 1) uniform distribution. |
Remove(KeyValuePair<String,OptionBase>) | Removes the first occurrence of a specific object from the ICollection<T>. |
Remove(String) | Removes the element with the specified key from the IDictionary<TKey,TValue>. |
SampleFromFeatureSpace(Double[]) |
sample from [0,1) uniform distribution. |
TryGetValue(String, OptionBase) | System.Object.TryGetValue(System.String,Microsoft.ML.SearchSpace.Option.OptionBase@) |
Explicit Interface Implementations
IEnumerable.GetEnumerator() | Returns an enumerator that iterates through a collection. |