Page 1 of 2

Start the discussion about BDe scoring module

PostPosted: Tue Jul 01, 2014 7:14 pm
by cwyoo
BDe module implements equation (35) from Heckerman's article that is post here. Start registering code in git and document the implementation.

Re: Start the discussion about BDe scoring module

PostPosted: Tue Jul 08, 2014 11:29 am
by cwyoo
I believe BDe scoring module has been checked into Git. Let me know how to check it out and how far are we on the implementation of the module. I would ask to have the following modules in implemeting the BDe scoring module:

BDeScore(BaysianNetwork bn, Dataset ds) {

for number of nodes (indexed i) {
for number of configurations of node i's parents (indexed j) {
for number of states of node i ( indexed k) {
// get Nijk, alpha_ijk from bn and ds
// we need to have a module to getNijk(i, j, k, bn, ds)
// note that Nij = getNijk(i, j, 0, bn, ds) + getNijk(i, j, 1, bn, ds) + ... + getNijk(i, j, r_i, bn, ds)
// also alpha_ijk = 1/(r_i*q_i) and alpha_ij = 1/q_i

// add log gamma functions for Nijk, alpha_ijk in equation (35)
}
// add log gamma functions for Nij, alpha_ij in equation (35)
}
}

Re: Start the discussion about BDe scoring module

PostPosted: Tue Jul 15, 2014 10:16 am
by cwyoo
cwyoo wrote:I believe BDe scoring module has been checked into Git. Let me know how to check it out and how far are we on the implementation of the module. I would ask to have the following modules in implemeting the BDe scoring module:

BDeScore(BaysianNetwork bn, Dataset ds) {

for number of nodes (indexed i) {
for number of configurations of node i's parents (indexed j) {
for number of states of node i ( indexed k) {
// get Nijk, alpha_ijk from bn and ds
// we need to have a module to getNijk(i, j, k, bn, ds)
// note that Nij = getNijk(i, j, 0, bn, ds) + getNijk(i, j, 1, bn, ds) + ... + getNijk(i, j, r_i, bn, ds)
// also alpha_ijk = 1/(r_i*q_i) and alpha_ij = 1/q_i

// add log gamma functions for Nijk, alpha_ijk in equation (35)
}
// add log gamma functions for Nij, alpha_ij in equation (35)
}
}


Michael/Abhilash, could you update me with the status on the implemtation of this module?

Re: Start the discussion about BDe scoring module

PostPosted: Tue Jul 15, 2014 11:59 am
by cwyoo
cwyoo wrote:
cwyoo wrote:I believe BDe scoring module has been checked into Git. Let me know how to check it out and how far are we on the implementation of the module. I would ask to have the following modules in implemeting the BDe scoring module:

BDeScore(BaysianNetwork bn, Dataset ds) {

for number of nodes (indexed i) {
for number of configurations of node i's parents (indexed j) {
for number of states of node i ( indexed k) {
// get Nijk, alpha_ijk from bn and ds
// we need to have a module to getNijk(i, j, k, bn, ds)
// note that Nij = getNijk(i, j, 0, bn, ds) + getNijk(i, j, 1, bn, ds) + ... + getNijk(i, j, r_i, bn, ds)
// also alpha_ijk = 1/(r_i*q_i) and alpha_ij = 1/q_i

// add log gamma functions for Nijk, alpha_ijk in equation (35)
}
// add log gamma functions for Nij, alpha_ij in equation (35)
}
}


Michael/Abhilash, could you update me with the status on the implemtation of this module?


I suggest we implement the BDeScoring() in the following way so we can utilize some API when we are scoring the order (see discussion about orderling score):

logNodeScore(NodeIdx i, long r_i, ParentIndices *pidxArray, ParentsNumOfStates pnumStateArray, DataSet ds) {

for number of configurations of node i's parents (indexed j) {
for number of states of node i ( indexed k) {
// get Nijk, alpha_ijk from bn and ds
// we need to have a module to getNijk(i, j, k, bn, ds)
// note that Nij = getNijk(i, j, 0, bn, ds) + getNijk(i, j, 1, bn, ds) + ... + getNijk(i, j, r_i, bn, ds)
// also alpha_ijk = 1/(r_i*q_i) and alpha_ij = 1/q_i

// add log gamma functions for Nijk, alpha_ijk in equation (35)
}
// add log gamma functions for Nij, alpha_ij in equation (35)
}
// return the score
}


logBDeScore(BaysianNetwork bn, Dataset ds) {

for number of nodes in bn (indexed i) {
// create an array of index for node i's parents and store in ParentIndices *pidxArray
// sum up the returns of logNodeScore(NodeIdx i,long r_i, ParentIndices *pidxArray, ParentsNumOfStates pnumStateArray, DataSet ds)
}
// return the summed score
}

Re: Start the discussion about BDe scoring module

PostPosted: Wed Jul 16, 2014 1:29 pm
by M Charles
I am still working on coding up this scoring module and will be changing it to be closer to your recommended pseudocode (with some changes based on SMILE's API).

My current code uses a "refcounted_dataset" class (which contains the DSL_dataset object). Inside this class I have member functions for scoring networks, nodes, etc. Later on, derived classes can be made that will override the Nijk function (for tree-based, hash-based, etc).

On another note, I have a question on precision. Is there a large enough risk of underflow/overflow so that I should use a long double (18-decimal digits of precision on our server) rather than a double (15-decimal digits)? This changes the exponents from -308/+308 to -4932/+4932, but will increase computation time by some amount.

Re: Start the discussion about BDe scoring module

PostPosted: Wed Jul 16, 2014 8:28 pm
by cwyoo
Michael Cho wrote:I am still working on coding up this scoring module and will be changing it to be closer to your recommended pseudocode (with some changes based on SMILE's API).

My current code uses a "refcounted_dataset" class (which contains the DSL_dataset object). Inside this class I have member functions for scoring networks, nodes, etc. Later on, derived classes can be made that will override the Nijk function (for tree-based, hash-based, etc).

On another note, I have a question on precision. Is there a large enough risk of underflow/overflow so that I should use a long double (18-decimal digits of precision on our server) rather than a double (15-decimal digits)? This changes the exponents from -308/+308 to -4932/+4932, but will increase computation time by some amount.


For now, double will be fine.

Re: Start the discussion about BDe scoring module

PostPosted: Wed Aug 06, 2014 11:07 am
by cwyoo
Michael, please post your progress here by today. Also please update the documentation sections accordingly so we can start the discussions. Note that post whatever you have upto today. We will revise and update from there.

Re: Start the discussion about BDe scoring module

PostPosted: Mon Nov 21, 2016 1:02 pm
by qja0428
The attachment is all the plots with bde score from my implementation and r, the two cde scores are not exactly the same, but they are close, I think my implementation is fine, we can move on to next: bde score with tree structure.

Re: Start the discussion about BDe scoring module

PostPosted: Thu Nov 24, 2016 6:16 pm
by cwyoo
qja0428 wrote:The attachment is all the plots with bde score from my implementation and r, the two cde scores are not exactly the same, but they are close, I think my implementation is fine, we can move on to next: bde score with tree structure.


Great. Please post your implementation in Git with e.s.s. as an user input (default = 1.0)

Re: Start the discussion about BDe scoring module

PostPosted: Mon Nov 28, 2016 10:33 am
by lsand039
Here are some dot file examples.