inferlo.GraphModel
- class inferlo.GraphModel[source]
Abstract class representing any graphical model.
- __init__(num_variables: int, domain: Domain)[source]
- Parameters:
num_variables – Number of variables in the model.
domain – Default domain of each variable.
Methods
__init__
(num_variables, domain)add_factor
(factor)Adds a factor to the model.
Draws the factor graph.
evaluate
(x)Returns value of non-normalized pdf in point.
Builds factor graph for the model.
Returns all factors.
Returns the biggest domain size over all variables.
Prepares variables for usage in expressions.
get_variable
(idx)Returns variable by its index.
Returns all variables.
infer
([algorithm])Performs inference.
max_likelihood
([algorithm])Finds the most probable state.
Evaluates most likely state in a very inefficient way.
Evaluates partition function in very inefficient way.
sample
(num_samples[, algorithm])Generates samples.
- evaluate(x: ndarray) float [source]
Returns value of non-normalized pdf in point.
In other words, just substitutes values into factors and multiplies them.
- get_factor_graph() Tuple[Graph, Dict[int, str]] [source]
Builds factor graph for the model.
Factor graph is a bipartite graph with variables in one part and factors in other graph. Edge denotes that factor depends on variable.
- get_symbolic_variables() List[FunctionFactor] [source]
Prepares variables for usage in expressions.
Returns lists of trivial
FunctionFactor
s, each of them representing a factor on one variable with identity function. They can be used in mathematical expressions, which will result in anotherFunctionFactor
.