Closed PARODBE closed 2 years ago
Can you show a reference what you exactly mean with the smooth parameter and the AODE model.
Sure. Regarding smooth param, In bnclassify for example: https://github.com/bmihaljevic/bnclassify/blob/master/R/0bnclassify-doc.R : "The smoothing value (\eqn{\alpha}) for Bayesian #' parameter estimation. Nonnegative. \eqn{\alpha =
For me It is more clear implement it from scratch like this for example: https://kenzotakahashi.github.io/naive-bayes-from-scratch-in-python.html Here you have the implementation of smooth parameter in a naive bayes, multinomial naive bayes etc...
Respect AODE model: https://rdrr.io/github/bmihaljevic/bnclassify/src/R/bncs.R
Let me know if it is enough or you need more information please.
Thanks for all @erdogant !
Pablo
Thanks for the links! A lot to read I see ;-)
Hi @erdogant , I made the same question in pgmpy, and I am going to paste the answer for you, because they already have a solution implemented and may be this is easier add in your library, I don't know:
@PARODBE Sorry for the late reply. If I am understanding correctly, the smooth parameter in bnclassify is equivalent to providing a pseudo_counts for each state when estimating the parameters. It should be equivalent to using BayesianEstimator with dirichlet prior in pgmpy. Here's an example with data generated from the alarm model and trying to learn the parameters of the model back from the simulated data. The pseudo_counts parameter should be equivalent to the smooth parameter in bnclassify.
In [1]: from pgmpy.estimators import BayesianEstimator
In [2]: from pgmpy.utils import get_example_model
In [3]: from pgmpy.models import BayesianNetwork
In [4]: model = get_example_model('alarm')
In [5]: df = model.simulate(int(1e4)) Generating for node: BP: 100%|████████████████████████████████████████████| 37/37 [00:00<00:00, 299.29it/s] /home/ankur/pgmpy/pgmpy/models/BayesianNetwork.py:1227: FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead. return samples.loc[:, set(self.nodes()) - self.latents]
In [6]: new_model = BayesianNetwork(model.edges())
In [7]: cpds = BayesianEstimator(new_model, df).get_parameters(prior_type='dirichlet', pseudo_counts=1)
In [8]: new_model.add_cpds(*cpds)
Thank you for letting me know! I did add the smooth parameter in the latest version now.
Thank you !!:)
Hi @erdogant ,
One question, I don't know if we speak about smooth parameter, but could you incorporate? It is a very importante parameter, but it is possible that we spoke about this and may be you already incorporated.
And another thing could you incorporate AODE model? It is very interesting and in bnclassify or bnlearn of r is available.
Thanks for all!
Pablo