BAMT icon indicating copy to clipboard operation
BAMT copied to clipboard

How can I use BIC instead of K2 score?

Open EsqYu opened this issue 1 year ago • 5 comments

Hi.

I wonder how I can use BIC score instead of K2 score in the add_edges method. I executed the code below, changing scoring function since K2 score seems to be used only in a case that all the variables are discretized. However, it didn't work and the error message says "Hybrid BN does not support continuous data".

from pgmpy.estimators import BicScore hybrid_bn = HybridBN(has_logit=False, use_mixture=True) hybrid_bn.add_edges(data, scoring_function=("Bic",BicScore)) hybrid_bn.fit_parameters(data)

EsqYu avatar Jul 03 '24 09:07 EsqYu

BicScore also only works with discretized data. Currently, structural learning can only be done on discretized data, while parameters learning can be done on initial data without discretization.

Anaxagor avatar Jul 03 '24 09:07 Anaxagor

Thank you for your reply. Then, if I want to apply BAMT on mixed or continuous data without discretization, all I can do is parameters learning? When I only do parameters learning, just execute bn.fit_parameters()?

EsqYu avatar Jul 03 '24 10:07 EsqYu

Yes, parameters learning you can apply without discretization via function bn.fit_parameters().

Anaxagor avatar Jul 03 '24 10:07 Anaxagor

Thank you. I'm just wondering how I can do parameters learning without structure learning. In that case, should I use other algorithm and determine the structure and then use this bn.fit_parameters?

EsqYu avatar Jul 04 '24 01:07 EsqYu

The structure must be specified anyway in a Bayesian network, this can be done by simply passing a list of edges to the method bn.set_structure(edges=structure). Parametric training can then be run as before bn.fit_parameters. There is an example in the documentation https://bamt.readthedocs.io/en/latest/examples/read_structure_param_learning.html

Anaxagor avatar Jul 05 '24 10:07 Anaxagor