{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exact Inference in Graphical Models"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Inference\n",
"Inference is same as asking conditional probability questions to the models. So in our student example we might would have liked to know what is the probability of a student getting a good grade given that he is intelligent which is basically equivalent of asking $ P(g^1 | i^1) $. Inference algorithms deals with efficiently finding these conditional probability queries.\n",
"\n",
"There are two main categories for inference algorithms:\n",
"1. Exact Inference: These algorithms find the exact probability values for our queries.\n",
"2. Approximate Inference: These algorithms try to find approximate values by saving on computation."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exact Inference\n",
"There are multiple algorithms for doing exact inference. We will mainly be talking about two very common algorithms in this notebook:\n",
"1. Variable Elimination\n",
"2. Clique Tree Belief Propagation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Variable Elimination\n",
"The basic concept of variable elimination is same as doing marginalization over Joint Distribution. But variable elimination avoids computing the Joint Distribution by doing marginalization over much smaller factors. So basically if we want to eliminate $ X $ from our distribution, then we compute the product of all the factors involving $ X $ and marginalize over them, thus allowing us to work on much smaller factors. Let's take the student example to make things more clear:\n",
"\n",
"$$ P(D) = \\sum_I \\sum_S \\sum_G \\sum_L P(D, I, S, G, L) $$\n",
"$$ P(D) = \\sum_I \\sum_S \\sum_G \\sum_L P(D) * P(I) * P(S | I) * P(G | D, I) * P(L | G) $$\n",
"$$ P(D) = P(D) \\sum_S P(S | I) \\sum_I P(I) \\sum_G P(G | D, I) \\sum_L P(L | G) $$\n",
"\n",
"In the above equation we can see that we pushed the summation inside and operated the summation only factors that involved that variable and hence avoiding computing the complete joint distribution.\n",
"\n",
"Let's now see some code examples:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Add code examples for Variable Elimination"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Clique Tree Belief Propagation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 1
}