Skip to content

Conversation

@ZJsheep
Copy link
Contributor

@ZJsheep ZJsheep commented Dec 16, 2025

According to the Bernoulli edge-based structure prior combined with the BDeu marginal likelihood, the structure prior can be written as

$$ \log p(G) = \sum_{i=1}^{d} \left[ |PA_i| \log\left(\frac{\kappa}{d-1}\right) + (d - 1 - |PA_i|)\log\left(1 - \frac{\kappa}{d-1}\right) \right], $$

where $d$ denotes the number of variables (features), since each node can have at most $d-1$ possible parents.

In the original implementation, however, the Data array has shape (number_of_samples, number_of_variables). Therefore, Data.shape[1] should be used instead of Data.shape[0] when computing the structure prior.

Fix calculation of vm to use the number of columns (number of variables) instead of rows (number of samples).

Signed-off-by: Zhou Jiayang <73184640+ZJsheep@users.noreply.github.com>
@ZJsheep ZJsheep changed the title Fix implementation of the structure score term of the BDeu score Fix implementation of the structure prior term of the BDeu score Dec 16, 2025
@zhi-yi-huang zhi-yi-huang requested review from zhi-yi-huang and removed request for zhi-yi-huang December 21, 2025 15:33
Copy link
Collaborator

@zhi-yi-huang zhi-yi-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@kunwuz kunwuz merged commit 16d6db9 into py-why:main Dec 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants