Matching model to data

The engine.
Post Reply
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Matching model to data

Post by lizbona »

Hi, I have an appplication where I need to match networks model to dataSet. It will be used due to learn networks parameters via EM algorithm. I have in my applications logic recorded which models nodes are connected with which dataSet columns. I assume that I need to use EM learn method with DataMatch table. One dataMatch equals one node-column matching. But my question is how I tell learn method which outcomes of concrete node goes with concrete columns state? All this connections are set in my application logic, but I don't know how to put it in smile.
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Post by lizbona »

Hi, I have also problem which is not connected with subject. When I try to change target property of node in network I get native error such:

Code: Select all

smile.SMILEException: Cannot change target status for node 'Node1'
at smile.Network.setTarget(Native Method)
Is there need to be fulfilled some extra condition to change nodes target status?
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

lizbona wrote:Hi, I have also problem which is not connected with subject. When I try to change target property of node in network I get native error such:

Code: Select all

smile.SMILEException: Cannot change target status for node 'Node1'
at smile.Network.setTarget(Native Method)
Is there need to be fulfilled some extra condition to change nodes target status?
Your program probably calls setTarget(nodeHandle, true) on a node which is already a target (alternatively, it may be setTarget(nodeHandle, false) for a non-target node).
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Re: Matching model to data

Post by shooltz[BayesFusion] »

lizbona wrote:But my question is how I tell learn method which outcomes of concrete node goes with concrete columns state?
EM doesn't do match outcomes - it uses raw indices from the DataSet and passes them to setEvidence internally. The optional "state names" managed by DataSet are ignored by EM if they're present.
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Post by lizbona »

Hi, thank you for reply. My problem with setting target is solved. It was indeed problem with setting the same 'target state' to node as it was before. But according to first problem, if EM doesn't match the outcomes, then what is the reason of doing connections between the outcomes in genie, right before learning parameters?
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

lizbona wrote:But according to first problem, if EM doesn't match the outcomes, then what is the reason of doing connections between the outcomes in genie, right before learning parameters?
GeNIe creates a temporary DSL_dataset object for EM. This dataset may contain translated integer indices based on the matchings selected by the user.
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Post by lizbona »

Hi again, I still try to face this problem. So if I want to match outcomes, then I need to reread dataSet from its file. Then if variable has states 's1_below_33', 's2_33_42' and 's3_42_up' and second state is connected with first model outcome and third with second then I need to call setStateNames() method with correct states order(2, 3, 1) and finnally replace in dataSet all the states with that new order?
I have one more question about DataMatch class. I need also construct array of this objects to learn EM method. Each object has 3 attributes inside. 'Column' is variableId from DataSet and 'node' is nodeHandle from Network, am I right? But what is 'slice' attribute? And one more question what is the method matchNetwork on DataSet class for? I set my network as parameter but exception occured

Code: Select all

smile.SMILEException: No matches found
at smile.learning.DataSet.matchNetwork(Native Method)
Regards
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

lizbona wrote:Hi again, I still try to face this problem. So if I want to match outcomes, then I need to reread dataSet from its file. Then if variable has states 's1_below_33', 's2_33_42' and 's3_42_up' and second state is connected with first model outcome and third with second then I need to call setStateNames() method with correct states order(2, 3, 1) and finnally replace in dataSet all the states with that new order?
If the data file has names (not indices) and you're calling DataSet.matchNetwork (see below), then you should be OK. If the file has indices and you're about to call EM, then setStateNames call is effectively ignored, because EM doesn't use the information about state names (the raw indices are passed to setEvidence). In such case you'll be fine if indices fit into ordering of node states. Otherwise you need to change the indices before EM runs.


I have one more question about DataMatch class. I need also construct array of this objects to learn EM method. Each object has 3 attributes inside. 'Column' is variableId from DataSet
DataMatch.column is a 0-based integer index of variable in the DataSet - the same value which you pass to methods like DataSet.getInt or DataSet.getVariableId as 1st argument. The variableId is a string.
and 'node' is nodeHandle from Network, am I right? But what is 'slice' attribute?
'Node' is indeed node handle. Slice is the DBN slice, used only if you learn parameters in the dynamic network.

And one more question what is the method matchNetwork on DataSet class for? I set my network as parameter but exception occured

Code: Select all

smile.SMILEException: No matches found
at smile.learning.DataSet.matchNetwork(Native Method)
DataSet.matchNetwork looks for potential matchings in the specified network, and builds an array of DataMatch objects if anything is found. The variables and nodes matchings are based on the identifiers. DataSet.dataMatch will also match the node states with names in the data file.
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Post by lizbona »

Hi, thanks for response. I tried to create DataMatch table. I do it in below code snippet:

Code: Select all

index=0;
for(Pair pair : connection){
						ds.addIntVariable(pair.getVariableId());
						dataMatch[index] = new DataMatch();
						dataMatch[index].column = index;
						dataMatch[index++].node = net.getNode(pair.getNodeId());
					}
, where connection is list of logic connection(pairs) between network and DataSet. In this loop I recreate also dataSet into new one which will go to em.learn. After putting this dataMatch table into em.learn method:

Code: Select all

em.learn(newLearningSet, net, dm);
, I get fatal error. In log there are informations like:

Code: Select all

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~BufferBlob::jni_fast_GetLongField
C  [libjsmile.so+0x1048de]  Java_smile_learning_EM_learn__Lsmile_learning_DataSet_2Lsmile_Network_2_3Lsmile_learning_DataMatch_2_3I+0x11e
j  smile.learning.EM.learn(Lsmile/learning/DataSet;Lsmile/Network;[Lsmile/learning/DataMatch;[I)V+0
j  smile.learning.EM.learn(Lsmile/learning/DataSet;Lsmile/Network;[Lsmile/learning/DataMatch;)V+8
j  classes.logic.impl.KFoldModel.createModel(I)V+441
Am I creating dataMatch table in wrong way?
lizbona
Posts: 9
Joined: Mon Mar 22, 2010 12:38 pm

Post by lizbona »

ok, i guess problem solved, I was serving the refference to null network
Post Reply