<< Click to Display Table of Contents >> Navigation: Using SMILE > Learning > Learning network parameters |
To learn or refine parameters in an existing DSL_network object, you can use the EM algorithm implemented in DSL_em class. As with structure learning, the data comes in DSL_dataset object. However, the network and the data must be matched to ensure that learning algorithm knows the relationship between the data set variables and network nodes. If the variables and nodes have identical identifiers, you can use the DSL_dataset::MatchNetwork method:
DSL_dataset ds;
DSL_network net;
// load network and data here
vector<DSL_datasetMatch> matching;
string errMsg;
res = ds.MatchNetwork(net, matching, errMsg);
if (DSL_OKAY == res)
{
DSL_em em;
res = em.Learn(ds, net, matching);
}
If your network and data cannot be automatically matched with MatchNetwork, you can build a vector of DSL_datasetMatch structures in your own code. DSL_datasetMatch has node and column members representing node handle and variable index, respectively. For each node/variable pair you need one element of the matching vector.
DSL_em::Learn can be fine-tuned with various algorithm settings - see the DSL_em reference section for details. The method can also return log likelihood, ranging from minus infinity to zero, which is a measure of fit of the model to the data:
DSL_em em;
double logLik
res = em.Learn(ds, net, matching, &logLik);
It is possible to exclude some nodes from learning. These fixed nodes do not change their CPTs during parameter learning.
DSL_em em;
double loglik;
vector<int> fixedNodes;
// add node handles to fixedNodes here
res = em.Learn(ds, net, matching, fixedNodes, &loglik);