Issues with node states flip in parameter learning output

The engine.
Post Reply
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Issues with node states flip in parameter learning output

Post by Bo Hu »

Hello,
I am doing a simulation study, in which I use static EM to estimate the parameters of a BN. I assume that in SMILE the CPs are saved into a matrix based on the rule introduced in the manual and following the same rule, I extract CPs using the codes as follows. However, I noticed that there seems a flip of node states between different runs with different dataset.

For example, in my BN, a latent node B is dependent on a latent node A. Both nodes have two states: 0 = false; 1 = true. Therefore, I did not define states when creating the network. To generate the data, the true values for P (B=1|A=1) and P (B=1|A=0) are set to .60 and .40, respectively. Then, I ran static EM for 100 datasets. The seed is set to 0 for all runs. Below is part of the output I pulled out from CP tables using attached codes. It seems in the CP tables the order of the states of node B were randomly assigned. If so, is there any ways to fix it

dataset P_B_1_A_1 P_B_0_A_1 P_B_1_A_0 P_B_0_A_0
1 0.593043 0.406957 0.415188 0.584812
2 0.60443 0.39557 0.410549 0.589451
3 0.603798 0.396202 0.390583 0.609417
4 0.405125 0.594875 0.599858 0.400142
5 0.389113 0.610887 0.612045 0.387955
6 0.401198 0.598802 0.609971 0.390029

Thanks a lot!
Bo

Code: Select all

void staticEM() {
		
		DSL_dataset LT;

		std::string errMsg;
		int parseCode = LT.ReadFile("C:\\Users\\User\\Desktop\\C++\\LIN_4.txt", NULL, &errMsg);
		if (parseCode != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			cout << "Error code:" << parseCode << endl;
			cout << "Error message:" << errMsg << endl;
			exit(1);
		}

		if (LT.ReadFile("C:\\Users\\User\\Desktop\\C++\\LIN_4.txt") != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			exit(1);
		}
		DSL_network LIN_4T;
		if (LIN_4T.ReadFile("LIN_4T.xdsl", DSL_XDSL_FORMAT) != DSL_OKAY) {
			cout << "Cannot read network...exiting." << endl;
			exit(1);
		}
		vector<DSL_datasetMatch> matches;
		string err;
		if (LT.MatchNetwork(LIN_4T, matches, err) != DSL_OKAY) {
			cout << "Cannot match network...exiting." << endl;
			cout << err << endl;
			exit(1);
		}
		
		int seed = 0;
		double loglik;
		
		DSL_em em;
                em.DSL_em::SetSeed(seed);
		if (em.Learn(LT, LIN_4T, matches, &loglik) != DSL_OKAY) {
			cout << "Cannot learn parameters...exiting." << endl;
			exit(1);
		}


		LIN_4T.UpdateBeliefs();

		//ATTRIBUTE CPs
		int A = LIN_4T.FindNode("A");
		const DSL_Dmatrix* mtx_A = LIN_4T.GetNode(A)->Definition()->GetMatrix();
		double P_A_0 = (*mtx_A)[0];
		double P_A_1 = (*mtx_A)[1];

		int B = LIN_4T.FindNode("B");
		const DSL_Dmatrix* mtx_B = LIN_4T.GetNode(B)->Definition()->GetMatrix();
		double P_B_0_A_0 = (*mtx_B)[0];
		double P_B_1_A_0 = (*mtx_B)[1];
		double P_B_0_A_1 = (*mtx_B)[2];
		double P_B_1_A_1 = (*mtx_B)[3];
		
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

The seed is set to 0 for all runs.
This causes the initial parameters in the network (before main EM loop starts) to be randomized by using seed based on current time (so you're wiping out the parameters saved in the XDSL file), so each time you're getting different initial CPTs. Does this agree with your assumptions?
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

Thank you so much for the reply. Could you give me any suggestions or hints to fix this problem with my code?

I just want to make sure all parameters have a fixed position in the matrix/CP table so that I can know which is which when I extract them. And these positions will not change between runs with different datasets.

I assume the parameter's position is defined using the rule introduced in the tutorial: if A and B are two parents of Y, then the order of CPs with regard to Y should be:
1 p(Y=0|A=0,B=0)
2 p(Y=1|A=0,B=0)
3 P(Y=0|A=0,B=1)
4 p(Y=1|A=0,B=1)
5 p(Y=0|A=1,B=0)
6 p(Y=1|A=1,B=0)
7 P(Y=0|A=1,B=1)
8 p(Y=1|A=1,B=1)

But it seems my codes always give me random positions with a flip for Y=0 and Y=1 for some nodes and between runs.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

It's hard to say without seeing your network and data what's causing the problem. One possible reason is that
a) you're randomizing the network parameters using different seed (remember, the zero seed means different value each time).
b) the data file is too small to change the initial randomized parameters; sometimes the initial CPTs will be too skewed too far towards one stateand EM will not change them sufficiently.

I'd try calling SetRandomizeParameters(false) and SetUniformizeParameters(true) on your EM object before learning. If you still see unexpected behavior after this change, post your data/network here.
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

Thanks! Here is my code.

My data was saved in C:\\Users\\b445h711\\Desktop\\c500\\data_l500.csv. It contains 10000 rows and 14850 columns, representing 495 datasets. In each dataset, there are 10000 rows (observations) and 30 columns representing 30 binary variables (1 = true,0=false). In the network, nodes A, B, C, D are four latent variables. They have a dependence relation A --->B----->C----->D.

So using my code each time I feed the main EM loop a dataset to match the network and estimate the parameters.

I really appreciate your time and help!!


Code: Select all


#include "stdafx.h"
#define _SECURE_SCL 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <iterator>
#include "smile.h"
#include "smilearn.h"


using namespace std;

	void CreateNetwork(void) {
		DSL_network LIN_4T;
		int x1 = LIN_4T.AddNode(DSL_CPT, "x1");
		int x2 = LIN_4T.AddNode(DSL_CPT, "x2");
		int x3 = LIN_4T.AddNode(DSL_CPT, "x3");
		int x4 = LIN_4T.AddNode(DSL_CPT, "x4");
		int x5 = LIN_4T.AddNode(DSL_CPT, "x5");
		int x6 = LIN_4T.AddNode(DSL_CPT, "x6");
		int x7 = LIN_4T.AddNode(DSL_CPT, "x7");
		int x8 = LIN_4T.AddNode(DSL_CPT, "x8");
		int x9 = LIN_4T.AddNode(DSL_CPT, "x9");
		int x10 = LIN_4T.AddNode(DSL_CPT, "x10");
		int x11 = LIN_4T.AddNode(DSL_CPT, "x11");
		int x12 = LIN_4T.AddNode(DSL_CPT, "x12");
		int x13 = LIN_4T.AddNode(DSL_CPT, "x13");
		int x14 = LIN_4T.AddNode(DSL_CPT, "x14");
		int x15 = LIN_4T.AddNode(DSL_CPT, "x15");
		int x16 = LIN_4T.AddNode(DSL_CPT, "x16");
		int x17 = LIN_4T.AddNode(DSL_CPT, "x17");
		int x18 = LIN_4T.AddNode(DSL_CPT, "x18");
		int x19 = LIN_4T.AddNode(DSL_CPT, "x19");
		int x20 = LIN_4T.AddNode(DSL_CPT, "x20");
		int x21 = LIN_4T.AddNode(DSL_CPT, "x21");
		int x22 = LIN_4T.AddNode(DSL_CPT, "x22");
		int x23 = LIN_4T.AddNode(DSL_CPT, "x23");
		int x24 = LIN_4T.AddNode(DSL_CPT, "x24");
		int x25 = LIN_4T.AddNode(DSL_CPT, "x25");
		int x26 = LIN_4T.AddNode(DSL_CPT, "x26");
		int x27 = LIN_4T.AddNode(DSL_CPT, "x27");
		int x28 = LIN_4T.AddNode(DSL_CPT, "x28");
		int x29 = LIN_4T.AddNode(DSL_CPT, "x29");
		int x30 = LIN_4T.AddNode(DSL_CPT, "x30");

		int A = LIN_4T.AddNode(DSL_CPT, "A");
		int B = LIN_4T.AddNode(DSL_CPT, "B");
		int C = LIN_4T.AddNode(DSL_CPT, "C");
		int D = LIN_4T.AddNode(DSL_CPT, "D");

		LIN_4T.AddArc(A, x1);
		LIN_4T.AddArc(B, x2);
		LIN_4T.AddArc(C, x3);
		LIN_4T.AddArc(D, x4);
		LIN_4T.AddArc(A, x5);
		LIN_4T.AddArc(B, x5);
		LIN_4T.AddArc(A, x6);
		LIN_4T.AddArc(C, x6);
		LIN_4T.AddArc(A, x7);
		LIN_4T.AddArc(D, x7);
		LIN_4T.AddArc(B, x8);
		LIN_4T.AddArc(C, x8);
		LIN_4T.AddArc(B, x9);
		LIN_4T.AddArc(D, x9);
		LIN_4T.AddArc(C, x10);
		LIN_4T.AddArc(D, x10);
		LIN_4T.AddArc(A, x11);
		LIN_4T.AddArc(B, x12);
		LIN_4T.AddArc(C, x13);
		LIN_4T.AddArc(D, x14);
		LIN_4T.AddArc(A, x15);
		LIN_4T.AddArc(B, x15);
		LIN_4T.AddArc(A, x16);
		LIN_4T.AddArc(C, x16);
		LIN_4T.AddArc(A, x17);
		LIN_4T.AddArc(D, x17);
		LIN_4T.AddArc(B, x18);
		LIN_4T.AddArc(C, x18);
		LIN_4T.AddArc(B, x19);
		LIN_4T.AddArc(D, x19);
		LIN_4T.AddArc(C, x20);
		LIN_4T.AddArc(D, x20);
		LIN_4T.AddArc(A, x21);
		LIN_4T.AddArc(B, x22);
		LIN_4T.AddArc(C, x23);
		LIN_4T.AddArc(D, x24);
		LIN_4T.AddArc(A, x25);
		LIN_4T.AddArc(B, x25);
		LIN_4T.AddArc(A, x26);
		LIN_4T.AddArc(C, x26);
		LIN_4T.AddArc(A, x27);
		LIN_4T.AddArc(D, x27);
		LIN_4T.AddArc(B, x28);
		LIN_4T.AddArc(C, x28);
		LIN_4T.AddArc(B, x29);
		LIN_4T.AddArc(D, x29);
		LIN_4T.AddArc(C, x30);
		LIN_4T.AddArc(D, x30);

		LIN_4T.AddArc(A, B);
		LIN_4T.AddArc(B, C);
		LIN_4T.AddArc(C, D);


		LIN_4T.WriteFile("LIN_4T.xdsl");
	}


	void staticEM() {
		
		DSL_dataset LT;

		std::string errMsg;
		int parseCode = LT.ReadFile("C:\\Users\\b445h711\\Desktop\\C++\\LIN_4.txt", NULL, &errMsg);
		if (parseCode != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			cout << "Error code:" << parseCode << endl;
			cout << "Error message:" << errMsg << endl;
			exit(1);
		}

		if (LT.ReadFile("C:\\Users\\b445h711\\Desktop\\C++\\LIN_4.txt") != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			exit(1);
		}
		DSL_network LIN_4T;
		if (LIN_4T.ReadFile("LIN_4T.xdsl", DSL_XDSL_FORMAT) != DSL_OKAY) {
			cout << "Cannot read network...exiting." << endl;
			exit(1);
		}
		vector<DSL_datasetMatch> matches;
		string err;
		if (LT.MatchNetwork(LIN_4T, matches, err) != DSL_OKAY) {
			cout << "Cannot match network...exiting." << endl;
			cout << err << endl;
			exit(1);
		}
		
		
		double loglik;
		
		DSL_em em;

		//em.SetUniformizeParameters(true);
		//em.SetRandomizeParameters(false);

		int seed = 0;
		em.DSL_em::SetSeed(seed);
		
		if (em.Learn(LT, LIN_4T, matches, &loglik) != DSL_OKAY) {
			cout << "Cannot learn parameters...exiting." << endl;
			exit(1);
		}


		LIN_4T.UpdateBeliefs();

		//ATTRIBUTE CPs
		int A = LIN_4T.FindNode("A");
		const DSL_Dmatrix* mtx_A = LIN_4T.GetNode(A)->Definition()->GetMatrix();
		double P_A_0 = (*mtx_A)[0];
		double P_A_1 = (*mtx_A)[1];

		int B = LIN_4T.FindNode("B");
		const DSL_Dmatrix* mtx_B = LIN_4T.GetNode(B)->Definition()->GetMatrix();
		double P_B_0_A_0 = (*mtx_B)[0];
		double P_B_1_A_0 = (*mtx_B)[1];
		double P_B_0_A_1 = (*mtx_B)[2];
		double P_B_1_A_1 = (*mtx_B)[3];

		int C = LIN_4T.FindNode("C");
		const DSL_Dmatrix* mtx_C = LIN_4T.GetNode(C)->Definition()->GetMatrix();
		double P_C_0_B_0 = (*mtx_C)[0];
		double P_C_1_B_0 = (*mtx_C)[1];
		double P_C_0_B_1 = (*mtx_C)[2];
		double P_C_1_B_1 = (*mtx_C)[3];


		int D = LIN_4T.FindNode("D");
		const DSL_Dmatrix* mtx_D = LIN_4T.GetNode(D)->Definition()->GetMatrix();
		double P_D_0_C_0 = (*mtx_D)[0];
		double P_D_1_C_0 = (*mtx_D)[1];
		double P_D_0_C_1 = (*mtx_D)[2];
		double P_D_1_C_1 = (*mtx_D)[3];

};





Last edited by Bo Hu on Thu Mar 09, 2017 7:20 pm, edited 2 times in total.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

I'm sorry, but your code is way too complex for me to analyze. You've added the calls to SetUniformizeParameters and SetRandomizeParameters, but they're commented out. What happens when you uniformize parameters before the EM?
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

Using SetUniformParameters (true), all estimated parameters with regard to nodes A, B, C and D are .50.

It seems they are not updated by EM.

Also, in the code posted above, I remove that part below staticEM (). I think the problem should be in the EM part.

Thanks, again!
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

It seems they are not updated by EM.
They are not.

Save your XDSL file and an example dataset (using DSL_dataset::WriteFile), then post it here as an attachment.
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

It's helpful to get your confirmation that the parameters are not updated. This seems to show me where I should go to find the problem. I will try myself first to see if it can be fixed...

Many thanks!
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

Check the number of elements in your 'matches' vector (the one which is filled for you by DSL_dataset::MatchNetwork). It may be empty - in such case there will be no evidence set in the network during EM. If this is the case, your node identifiers and column identifiers in the dataset do not match. Either ensure they do match or fill the matches vector yourself.
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

I have tried but still could not fix the issues. I have attached a dataset, a network file, and the output (including log-likelihood value) I pulled out for two datasets. From the output, it is obvious that the order of p (state =0) and p(state=1) flip between different nodes and EM runs with different datasets. The true parameter values used to generate the dataset is p = .10 for all state 0 and .90 for all state 1)

Also, I still got no clue for the reason why the CPs are not updated after adding SetUniformParameter(true). So, I posted my codes (for creating network and parameter learning) here again.

Code: Select all

#include "stdafx.h"
#define _SECURE_SCL 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <iterator>
#include "smile.h"
#include "smilearn.h"


using namespace std;

	void CreateNetwork(void) {
		DSL_network LIN_4T;
		int x1 = LIN_4T.AddNode(DSL_CPT, "x1");
		int x2 = LIN_4T.AddNode(DSL_CPT, "x2");
		int x3 = LIN_4T.AddNode(DSL_CPT, "x3");
		int x4 = LIN_4T.AddNode(DSL_CPT, "x4");
		int x5 = LIN_4T.AddNode(DSL_CPT, "x5");
		int x6 = LIN_4T.AddNode(DSL_CPT, "x6");
		int x7 = LIN_4T.AddNode(DSL_CPT, "x7");
		int x8 = LIN_4T.AddNode(DSL_CPT, "x8");
		int x9 = LIN_4T.AddNode(DSL_CPT, "x9");
		int x10 = LIN_4T.AddNode(DSL_CPT, "x10");
		int x11 = LIN_4T.AddNode(DSL_CPT, "x11");
		int x12 = LIN_4T.AddNode(DSL_CPT, "x12");
		int x13 = LIN_4T.AddNode(DSL_CPT, "x13");
		int x14 = LIN_4T.AddNode(DSL_CPT, "x14");
		int x15 = LIN_4T.AddNode(DSL_CPT, "x15");
		int x16 = LIN_4T.AddNode(DSL_CPT, "x16");
		int x17 = LIN_4T.AddNode(DSL_CPT, "x17");
		int x18 = LIN_4T.AddNode(DSL_CPT, "x18");
		int x19 = LIN_4T.AddNode(DSL_CPT, "x19");
		int x20 = LIN_4T.AddNode(DSL_CPT, "x20");
		int x21 = LIN_4T.AddNode(DSL_CPT, "x21");
		int x22 = LIN_4T.AddNode(DSL_CPT, "x22");
		int x23 = LIN_4T.AddNode(DSL_CPT, "x23");
		int x24 = LIN_4T.AddNode(DSL_CPT, "x24");
		int x25 = LIN_4T.AddNode(DSL_CPT, "x25");
		int x26 = LIN_4T.AddNode(DSL_CPT, "x26");
		int x27 = LIN_4T.AddNode(DSL_CPT, "x27");
		int x28 = LIN_4T.AddNode(DSL_CPT, "x28");
		int x29 = LIN_4T.AddNode(DSL_CPT, "x29");
		int x30 = LIN_4T.AddNode(DSL_CPT, "x30");

		int A = LIN_4T.AddNode(DSL_CPT, "A");
		int B = LIN_4T.AddNode(DSL_CPT, "B");
		int C = LIN_4T.AddNode(DSL_CPT, "C");
		int D = LIN_4T.AddNode(DSL_CPT, "D");

		LIN_4T.AddArc(A, x1);
		LIN_4T.AddArc(B, x2);
		LIN_4T.AddArc(C, x3);
		LIN_4T.AddArc(D, x4);
		LIN_4T.AddArc(A, x5);
		LIN_4T.AddArc(B, x5);
		LIN_4T.AddArc(A, x6);
		LIN_4T.AddArc(C, x6);
		LIN_4T.AddArc(A, x7);
		LIN_4T.AddArc(D, x7);
		LIN_4T.AddArc(B, x8);
		LIN_4T.AddArc(C, x8);
		LIN_4T.AddArc(B, x9);
		LIN_4T.AddArc(D, x9);
		LIN_4T.AddArc(C, x10);
		LIN_4T.AddArc(D, x10);
		LIN_4T.AddArc(A, x11);
		LIN_4T.AddArc(B, x12);
		LIN_4T.AddArc(C, x13);
		LIN_4T.AddArc(D, x14);
		LIN_4T.AddArc(A, x15);
		LIN_4T.AddArc(B, x15);
		LIN_4T.AddArc(A, x16);
		LIN_4T.AddArc(C, x16);
		LIN_4T.AddArc(A, x17);
		LIN_4T.AddArc(D, x17);
		LIN_4T.AddArc(B, x18);
		LIN_4T.AddArc(C, x18);
		LIN_4T.AddArc(B, x19);
		LIN_4T.AddArc(D, x19);
		LIN_4T.AddArc(C, x20);
		LIN_4T.AddArc(D, x20);
		LIN_4T.AddArc(A, x21);
		LIN_4T.AddArc(B, x22);
		LIN_4T.AddArc(C, x23);
		LIN_4T.AddArc(D, x24);
		LIN_4T.AddArc(A, x25);
		LIN_4T.AddArc(B, x25);
		LIN_4T.AddArc(A, x26);
		LIN_4T.AddArc(C, x26);
		LIN_4T.AddArc(A, x27);
		LIN_4T.AddArc(D, x27);
		LIN_4T.AddArc(B, x28);
		LIN_4T.AddArc(C, x28);
		LIN_4T.AddArc(B, x29);
		LIN_4T.AddArc(D, x29);
		LIN_4T.AddArc(C, x30);
		LIN_4T.AddArc(D, x30);

		LIN_4T.AddArc(A, B);
		LIN_4T.AddArc(B, C);
		LIN_4T.AddArc(C, D);
		LIN_4T.AddArc(A, C);
		LIN_4T.AddArc(A, D);
		LIN_4T.AddArc(B, D);

		LIN_4T.WriteFile("C:\\Users\\User\\Desktop\\C++\\LIN_4T.xdsl");
	}


	void staticEM() {
		
		DSL_dataset LT;

		std::string errMsg;
		int parseCode = LT.ReadFile("C:\\Users\\User\\Desktop\\C++\\LIN_4.txt", NULL, &errMsg);
		if (parseCode != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			cout << "Error code:" << parseCode << endl;
			cout << "Error message:" << errMsg << endl;
			exit(1);
		}

		if (LT.ReadFile("C:\\Users\\User\\Desktop\\C++\\LIN_4.txt") != DSL_OKAY) {
			cout << "Cannot read data file...exiting" << endl;
			exit(1);
		}
		DSL_network LIN_4T;
		if (LIN_4T.ReadFile("C:\\Users\\User\\Desktop\\C++\\LIN_4T.xdsl", DSL_XDSL_FORMAT) != DSL_OKAY) {
			cout << "Cannot read network...exiting." << endl;
			exit(1);
		}
		vector<DSL_datasetMatch> matches;
		string err;
		if (LT.MatchNetwork(LIN_4T, matches, err) != DSL_OKAY) {
			cout << "Cannot match network...exiting." << endl;
			cout << err << endl;
			exit(1);
		}
		
		
		double loglik;
		
		DSL_em em;
		
		//em.SetUniformizeParameters(true);
		//em.SetRandomizeParameters(false);
		
		em.DSL_em::SetSeed(0);
		
		if (em.Learn(LT, LIN_4T, matches, &loglik) != DSL_OKAY) {
			cout << "Cannot learn parameters...exiting." << endl;
			exit(1);
		}
	}
Attachments
output.txt
output
(3.95 KiB) Downloaded 375 times
LIN_4.txt
dataset
(129.42 KiB) Downloaded 359 times
LIN_4T.xdsl
network
(13 KiB) Downloaded 468 times
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with node states flip in parameter learning output

Post by shooltz[BayesFusion] »

I can confirm that your nodes A,B,C,D do not change their CPTs when starting from uniformized probabilities. Other nodes (with ids starting with x) do change the CPTs.

I've asked our EM expert if this is something to expect, given that A..D have no data in the dataset. I'll post a message once I know more.
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

Thank you so much!
marek [BayesFusion]
Site Admin
Posts: 430
Joined: Tue Dec 11, 2007 4:24 pm

Re: Issues with node states flip in parameter learning output

Post by marek [BayesFusion] »

[Edited Monday, 13 March 2017]

The behavior that you described in your original post is correct (different distributions for the latent variables when starting from different random priors). Latent variables have a lot of freedom in their probability distributions. As long as the joint p.d. over the variables present in the data are modeled correctly, most distributions among the latent variables are fine. It is correct that you may end up with various distributions over the latent variables -- they depend on the initial randomization and they will be compensated by the conditionals.

I have looked at your network and the data. What I find somewhat surprising is that you have arrows between the latent variables, A, B, C, and D. Setting their distributions to uniform practically makes the arrows useless. It is not common to have connections between latent variables. If you do, you should populate their CPTs and not change them (there are no data for the latent variables in your data set anyway).

As far as the distributions not changing, it is an artifact of uniform distributions, which provide for strong local maximums for the EM algorithm. You may be better off by putting in the latent variables your best estimates of the probabilities. If you keep the original parameters with low confidence, EM should not get into the funny behavior with uniform distributions.

I hope this helps.

Marek
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Re: Issues with node states flip in parameter learning output

Post by Bo Hu »

Thank you so much, Marek! This helps a lot.
Post Reply