jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.34k stars 589 forks source link

Sampling from conditional distributions in Bayesian Network. #921

Closed Wesserg closed 3 years ago

Wesserg commented 3 years ago

So.. in the Bayesian Networks patt we have the BayesianNetwork.sample() function, which does amazing job in sampling form the BNet distribution. But let's now say, that I know something about some variables and given that knowledge I want to sample (not predict) the remaining variables. Can I do that using existing functions?

I am looking for something in line with: BayesianNetwork.predict_proba(my conditions).sample()

Wesserg commented 3 years ago

Ahh... best rescue is self rescue:

the sample() function has an argument that is not mentioned in the API, it's called "evidences=[{}]" so BayesianNetwork.sample(n=N, evindences=[my_evidence_dict]) should solve the problem!

Right?

jmschrei commented 3 years ago

Yes. Sorry about the documentation oversight. The sample function was implemented by someone else.