I have successfully used some tools from the smilearn library to get a complete Bayesian network (structure + parameters) from a dataset. Right now I am trying to use EM, and I am facing several problems, probably arising from a combination of my own inexperience and missing/outdated parts in the tutorials.
My objective is to create a network, add the nodes, add some arcs, then learn the parameters from a dataset with no missing values. There are no hidden nodes.
Right now, my code resembles this:
Code: Select all
// Bayesian Network class from SMILE library
DSL_network network;
// dataset from SMILE library
DSL_dataset dataset;
string errOut;
if( dataset.ReadFile(fileName.c_str(), NULL, &errOut) != 0 )
{
cerr << "Error while reading file \"" << fileName << "\": " << errOut << endl;
exit(0);
}
// here I add the nodes, iterating over the variable names in the dataset, using network.AddNode(DSL_TABLE, nodeName)
// ...
// then, I add some arcs, using network.AddArc(handler1, handler2), finding the handlers with network.FindNode(nodeName)
// ...
// finally, I launch EM
DSL_em em;
vector<DSL_datasetMatch> matches;
string errMsg;
em.Learn(dataset, network, matches);
What am I doing wrong? Thank you in advance for your help!