Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscreteFactor parameter access #1

Open
carloslihu opened this issue Jun 14, 2022 · 2 comments
Open

DiscreteFactor parameter access #1

carloslihu opened this issue Jun 14, 2022 · 2 comments

Comments

@carloslihu
Copy link

carloslihu commented Jun 14, 2022

Brief Context

Hello, I find your library an excellent tool for Bayesian network research.
I'm currently trying to work with hybrid Bayesian networks (Discrete and Gaussian CPDs). In your library I have identified this as the CLGNetworkType.

Request

The issue is that I can't find in the documentation how to access the parameters (probabilities) in the Conditional Probability Table (CPT) of a DiscreteFactor.

I have seen it is possible with continuous factors (e.g., beta, variance).
But I would like to know if it's possible with the discrete ones.

Thank you very much.

@davenza
Copy link
Owner

davenza commented Oct 23, 2022

Hello Carlos,

for now, the easiest way to access the CPT is through the DiscreteFactor.logl() function.

I could provide alternative ways to access that info but I am not sure what is the best format to return it (probably, a multidimensional array?). Feel free to make any suggestions.

Regards.

@carloslihu
Copy link
Author

Hi David,

Thank you very much for the quick workaround. It is very helpful.
Regarding the best CPT output format, I know it's not trivial. However I can give you some ideas:

  • One of the problems I find is knowing the possible variable values.
    For instance, suppose we have a random variable A = {a1, a2}. I think that having a function returning a list with its possible values e.g., returning [a1, a2].

  • On the other hand, we have the problem of outputting the CPT probabilities in an intuitive way.
    I think that the best way is with a Pandas Multiindex Dataframe (https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html).
    To help you understand my idea, I have attached a Jupyter Notebook with a simple example:

CPT_output.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants