jmschrei / pomegranate

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

[QUESTION] Is structure learning from sample data supported in the latest version? #1100

Open williamagyapong opened 1 month ago

williamagyapong commented 1 month ago

Hello,

In version 0.14.8, it was possible to learn a Bayesian Network structure from sample data using the from_samples method. However, in version 1.0.4, I am unable to access this method from the network instance. If this feature is still supported, could you please advise on how to access it? If it is not currently available, I kindly request that it be included in a future update.

Thank you!

jmschrei commented 1 month ago

You can use the fit method to either fit parameters given a structure, or to learn the structure and parameters jointly if no structure is provided.

williamagyapong commented 1 month ago

Thank you very much for the quick response. I am finding it tricky to rewrite the following code, which is compatible with version 0.14.8, using the new API in version 1.0.4 with the fit method. In this code, source, and target are tabular datasets:

` import pandas as pd from pomegranate import BayesianNetwork

bn = BayesianNetwork.from_samples(source, algorithm="greedy", n_jobs=1) sample = pd.DataFrame(bn.sample(n=len(target), algorithm="rejection"), columns=source.columns) ` Any guidance on how to adapt this code to the new version would be greatly appreciated.