From 59e5794e5d6f3220e6ee99cdf351e4c9ea5c3b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Sun, 2 Jul 2023 11:39:12 +0200 Subject: [PATCH] Update info on README --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d210c5..4fd0db2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # BayesNet -Trying to implement Bayesian Network inference with libtorch from scratch +Bayesian Network Classifier with libtorch from scratch + +## Variable Elimination + +To decide the first variable to eliminate wel use the MinFill criterion, that is +the variable that minimizes the number of edges that need to be added to the +graph to make it triangulated. +This is done by counting the number of edges that need to be added to the graph +if the variable is eliminated. The variable with the minimum number of edges is +chosen. +In pgmpy this is done computing then the length of the combinations of the +neighbors taken 2 by 2. + +Once the variable to eliminate is chosen, we need to compute the factors that +need to be multiplied to get the new factor. +This is done by multiplying all the factors that contain the variable to +eliminate and then marginalizing the variable out. + +The new factor is then added to the list of factors and the variable to +eliminate is removed from the list of variables. + +The process is repeated until there are no more variables to eliminate. + +## Code for combination + +// Combinations of length 2 +vector combinations(vector source) +{ + vector result; + for (int i = 0; i < source.size(); ++i) { + string temp = source[i]; + for (int j = i + 1; j < source.size(); ++j) { + result.push_back(temp + source[j]); + } + } + return result; +}