BICCondGauss#
- class pgmpy.structure_score.BICCondGauss(data, state_names=None)[source]#
Bases:
LogLikelihoodCondGaussBIC 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 and the sample size. The local score is computed as:
\[\operatorname{BIC}(X_i, \Pi_i) = \ell(X_i, \Pi_i) - \frac{k_i}{2} \log n,\]where \(\ell(X_i, \Pi_i)\) is the local conditional-Gaussian log-likelihood, \(k_i\) is the number of free parameters returned by _get_num_parameters, and \(n\) is the number of rows in self.data.
- 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 BICCondGauss >>> 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 = BICCondGauss(data) >>> round(score.local_score("A", ("B", "C")), 3) np.float64(-146.529)