.. index:: Learning Wizard - EM Learning Help

.. _Learning_Wizard_EM_Learning_help:

EM Learning
===========

EM Learning is the process of learning the conditional probabilities for the variables from the data. It is an iterative process which improves the estimated conditional probabilities in each iteration. That is, the conditional probabilities will match the data better and better for each iteration.

It is possible to control the process to some extent by using two different parameters:

* maximum number of iterations for the process to run.
* convergence threshold.

Once these parameters have been specified, the Learning Wizard can complete the learning. When the conditional probability tables have been learned, the Learning Wizard will exit, and the learned model will be inserted into the Hugin GUI, for further use.

It is possible to skip the learning of the tables by selecting the check box at the bottom of the panel:

.. figure:: images/emlearning.png

If, however, EM-learning has been skipped, it is still possible to perform the learning "manually" by pressing the EM-learning button in the tool bar panel:

.. figure:: images/emlearning1.png

Maximum Number of Iterations
----------------------------

As described, EM learning is an iterative process, which continuously improves the resulting conditional probabilities. Setting the maximum number of iterations will force the learning process to terminate when it reaches that number (note, that it may terminate earlier, if the convergence threshold is reached). 

.. figure:: images/emlearning2.png

Setting the maximum number of iterations to zero will make the learning process disregard the maximum number of iterations.
Convergence Threshold
After each iteration, the EM learning will calculate the convergence. This is calculated as:

.. math:: Convergence = log Likelihood(n) - log Likelihood(n - 1)

Where n is the number of the current iteration, and where:
 
.. math:: log Likelihood(n) = \sum_{i = 0}^{caseCount - 1} P(case_i)

The learning will process will terminate when the convergence reaches a value smaller than the convergence threshold (or earlier, if the maximum number of iterations is reached). 
 
.. figure:: images/emlearning3.png

Note, that the convergence threshold must have a value larger than zero, for the Learning Wizard to finish.
