AICCondGauss#

class pgmpy.structure_score.AICCondGauss(data, state_names=None)[source]#

Bases: LogLikelihoodCondGauss

AIC structure score for Bayesian networks with mixed discrete and continuous variables.

This score penalizes the conditional-Gaussian log-likelihood by the number of free parameters. The local score computed by local_score(variable, parents) is

\[\operatorname{AIC}(X_i, \Pi_i) = \ell(X_i, \Pi_i) - k_i,\]

where \(\ell(X_i, \Pi_i)\) is the local conditional-Gaussian log-likelihood and \(k_i\) is the number of free parameters returned by _get_num_parameters.

Parameters:
datapandas.DataFrame

DataFrame where columns may be discrete or continuous variables.

state_namesdict, optional

Dictionary mapping discrete variable names to their possible states.

Raises:
ValueError

If the log-likelihood or parameter count cannot be computed for the given local configuration.

References

[1]

Andrews, B., Ramsey, J., & Cooper, G. F. (2018). Scoring Bayesian Networks of Mixed Variables. International Journal of Data Science and Analytics, 6(1), 3-18. https://doi.org/10.1007/s41060-017-0085-7

Examples

>>> import numpy as np
>>> import pandas as pd
>>> from pgmpy.structure_score import AICCondGauss
>>> rng = np.random.default_rng(0)
>>> data = pd.DataFrame(
...     {
...         "A": rng.normal(size=100),
...         "B": rng.integers(0, 2, size=100),
...         "C": rng.normal(size=100),
...     }
... )
>>> score = AICCondGauss(data)
>>> round(score.local_score("A", ("B", "C")), 3)
np.float64(-141.319)