Search Results for

    Show / Hide Table of Contents

    Interface IGeneratedAlgorithm

    Interface for running a generated inference algorithm

    Namespace: Microsoft.ML.Probabilistic
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    public interface IGeneratedAlgorithm

    Properties

    NumberOfIterationsDone

    The number of iterations done from the initial state or since the last change of observed values

    Declaration
    int NumberOfIterationsDone { get; }
    Property Value
    Type Description
    Int32
    Remarks

    Changing an observed value will reset this to 0.

    Methods

    Execute(Int32)

    Execute the inference algorithm for the specified number of iterations, starting from the initial state

    Declaration
    void Execute(int numberOfIterations)
    Parameters
    Type Name Description
    Int32 numberOfIterations

    The number of iterations to perform from the initial state

    Remarks

    Sets NumberOfIterationsDone = numberOfIterations. This method is equivalent to calling Reset() followed by Update(numberOfIterations).

    GetObservedValue(String)

    Gets an observed value

    Declaration
    object GetObservedValue(string variableName)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    Returns
    Type Description
    Object

    The observed value

    Marginal(String)

    Get the marginal distribution (computed up to this point) of a variable

    Declaration
    object Marginal(string variableName)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    Returns
    Type Description
    Object

    The marginal distribution computed up to this point

    Remarks

    Execute, Update, or Reset must be called first to set the value of the marginal.

    Marginal(String, String)

    Get the query-specific marginal distribution of a variable. For example, GibbsSampling answers "Marginal", "Samples", and "Conditionals" queries

    Declaration
    object Marginal(string variableName, string query)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    String query

    Query string

    Returns
    Type Description
    Object

    The query-specific marginal distribution computed up to this point

    Remarks

    Execute, Update, or Reset must be called first to set the value of the marginal.

    Marginal<T>(String)

    Get the marginal distribution (computed up to this point) of a variable, converted to type T

    Declaration
    T Marginal<T>(string variableName)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    Returns
    Type Description
    T

    The marginal distribution computed up to this point

    Type Parameters
    Name Description
    T

    The distribution type.

    Remarks

    Execute, Update, or Reset must be called first to set the value of the marginal. The conversion operation may be costly, even if the marginal already has type T. For maximum efficiency, use the non-generic Marginal method when conversion is not needed.

    Marginal<T>(String, String)

    Get the query-specific marginal distribution of a variable, converted to type T

    Declaration
    T Marginal<T>(string variableName, string query)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    String query

    Query

    Returns
    Type Description
    T

    The query-specific marginal distribution computed up to this point

    Type Parameters
    Name Description
    T

    Type to cast to

    Remarks

    Execute, Update, or Reset must be called first to set the value of the marginal. The conversion operation may be costly, even if the marginal already has type T. For maximum efficiency, use the non-generic Marginal method when conversion is not needed.

    Reset()

    Reset all messages to their initial values. Sets NumberOfIterationsDone to 0

    Declaration
    void Reset()
    Remarks

    This method is equivalent to calling Execute(0)

    SetObservedValue(String, Object)

    Sets an observed value

    Declaration
    void SetObservedValue(string variableName, object value)
    Parameters
    Type Name Description
    String variableName

    Name of the variable in the generated code

    Object value

    The observed value

    Update(Int32)

    Perform additional iterations of the inference algorithm

    Declaration
    void Update(int additionalIterations)
    Parameters
    Type Name Description
    Int32 additionalIterations

    The number of additional iterations to perform

    Remarks

    If no observed values have changed, this method increments NumberOfIterationsDone by additionalIterations, and is equivalent to calling Execute(NumberOfIterationsDone + additionalIterations). If some observed values have changed, this method sets NumberOfIterationsDone = additionalIterations, and is not equivalent to calling Execute, because it will start from the existing message state rather than the initial state.

    Events

    ProgressChanged

    Fired when the progress of inference changes, typically at the end of one iteration of the inference algorithm

    Declaration
    event EventHandler<ProgressChangedEventArgs> ProgressChanged
    Event Type
    Type Description
    EventHandler<ProgressChangedEventArgs>
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.