Defining CPT by a function instead of dictionary

Issue #47 closed
Pierre Denis repo owner created an issue

Currently, the lea.switch method requires the full CPT in the form of a dictionary. This CPT may be difficult to define if there are many entries or simply too large to fit in memory. As alternative, Lea provides the lea.cpt method that may factorize entries my means of boolean conditions on the influencing variables. However, lea.cpt only enables some kinds of factorization; also, the inference is usually slower than with lea.switch.

We propose a new approach to lea.switch. Instead of passing an explicit CPT dictionary, we could pass a function that mimics the CPT lookup: such function receives a value from the influencing variable (possibly a tuple from a joint of several variables), it has then to return a probability distribution depending of its argument. The inference algorithm should be able to use this function without expanding the full CPT.

The name of the new method could be switch_func. So, the construct

my_cpt_dict = {...}
my_lea_variable.switch(my_cpt_dict)

could be replaced by

def my_cpt_func(v):
    ...
my_lea_variable.switch_func(my_cpt_func)

The switch_func could then be useful to define noisy-or / noisy-max models.

Comments (6)

  1. Log in to comment