issues with DSL_em

The engine.
Post Reply
alamy
Posts: 8
Joined: Fri Sep 26, 2008 4:39 pm

issues with DSL_em

Post by alamy »

Hi,

I've tried to use DSL_em to learn the parameters of a three node network with the dataset from (http://genie.sis.pitt.edu/wiki/Tutorial ... Tutorial_4).

However, it seems that the learning is never successful (DSL_em::Learn(...) doesn't return a DSL_OK).

I wonder if I made any mistakes in using DSL_em? Is there a place where I can find a example on using it?

Following is my code segment.

Thanks.

///////////////////////////////////////////////////////////////////

DSL_dataset d;
DSL_idArray someNames;

d.ReadFile("c:\\temp\\b.txt");

DSL_network result;
DSL_em em;

int nc = result.AddNode(DSL_CPT, "c");
int nx = result.AddNode(DSL_CPT, "x");
int ny = result.AddNode(DSL_CPT, "y");

someNames.Add("State0");
someNames.Add("State1");

result.GetNode(nc)->Definition()->SetNumberOfOutcomes(someNames);
result.GetNode(nx)->Definition()->SetNumberOfOutcomes(someNames);
result.GetNode(ny)->Definition()->SetNumberOfOutcomes(someNames);

result.AddArc(nc,nx);
result.AddArc(nc,ny);

em.SetEquivalentSampleSize(10);

if (em.Learn(d,result)!=DSL_OKAY)
{
cout << "Learning failed." << endl;
return;
}


result.WriteFile("c:\\temp\\em.xdsl");


/*
b.txt:

c x y
State1 State1 State0
State1 State1 State0
State0 State1 State1
State0 State0 State0
State0 State0 State1
State0 State0 State1
State0 State1 State0
State0 State0 State1
State0 State1 State1
State0 State1 State1

*/
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: issues with DSL_em

Post by shooltz[BayesFusion] »

Try calling d.MatchNetwork before the learning (but after the nodes have been created and initialized).
alamy
Posts: 8
Joined: Fri Sep 26, 2008 4:39 pm

Re: issues with DSL_em

Post by alamy »

shooltz wrote:Try calling d.MatchNetwork before the learning (but after the nodes have been created and initialized).

That fixes the problem. Thanks a lot:)
Post Reply