Class IsBDeuScore
- All Implemented Interfaces:
IsScore
This score extends the standard Bayesian Dirichlet equivalent uniform (BDeu) score to the instance-specific setting described by Fattaneh Jabbari. In addition to the usual population-wide likelihood, it incorporates likelihood contributions from a designated test case (a single row from a dataset). The resulting score therefore rewards structures that not only fit the overall data but also provide a good explanation for the chosen instance.
The score is decomposable, so local score differences can be evaluated for candidate edge additions, deletions, or reversals. Each local computation blends:
- Population term: the standard BDeu contribution based on counts over the training dataset.
- Instance-specific term: a correction that favors parent configurations consistent with the observed values in the test case.
This hybrid design allows search algorithms such as IS-FGES and IS-GFCI to guide edge orientation using both population regularities and individual evidence, yielding graphs that may differ across test cases while remaining anchored to the population model.
References: Fattaneh Jabbari, Ph.D. dissertation, Carnegie Mellon University, pp. 144–147.
-
Constructor Summary
ConstructorsConstructorDescriptionIsBDeuScore(DataSet dataSet, DataSet testCase) Initializes the ISBDeuScore with the given dataset and test case. -
Method Summary
Modifier and TypeMethodDescriptionbooleandetermines(List<Node> z, Node y) Determines whether a given node y is determined by a list of nodes z.Retrieves a DataSet object.doubleRetrieves the value of the variable representing the k_addition.doubleRetrieves the value of the k_deletion field.doubleRetrieves the value of the k_reorient variable.intCalculates the maximum degree based on the sample size.int[]getParentValues(int nodeIndex, int rowIndex, int[] dims) Computes the parent values for a given node index and row index according to the specified dimensions.int[]getParentValuesForCombination(int rowIndex, int[] dims) Calculates the parent values for a given combination of dimensions.doubleRetrieves the prior value of the sample.intRetrieves the current sample size.doubleRetrieves the value of the structure prior.getVariable(String targetName) Retrieves a Node from the variables list that matches the specified target name.Retrieves the list of variables associated with this instance.booleanisEffectEdge(double bump) Must be called directly after the corresponding scoring call.doublelocalScore(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Calculates the local scoring for a given node in a Bayesian Network based on the provided parent and child configurations.doublelocalScore1(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Computes the local score for a given node considering both population and context-specific parents.doublelocalScoreDiff(int x, int y, int[] z, int[] z_pop, int[] child_pop) Computes the difference in local scores when element x is appended to the array z.voidsetKAddition(double k_addition) Sets the value of k_addition.voidsetKDeletion(double k_deletion) Sets the value of k_deletion.voidsetKReorientation(double k_reorient) Sets the value of the K-reorientation parameter.voidsetSamplePrior(double samplePrior) Sets the value for the samplePrior field.voidsetStructurePrior(double structurePrior) Sets the structure prior for the model.voidsetVariables(List<Node> variables) Sets the list of variables after validating that each variable in the provided list has the same name as the corresponding variable in the existing list.
-
Constructor Details
-
IsBDeuScore
Initializes the ISBDeuScore with the given dataset and test case.- Parameters:
dataSet- the dataset to be used for scoring. Must not be null.testCase- the test case to evaluate. Must not be null.- Throws:
NullPointerException- if either dataSet or testCase is null.
-
-
Method Details
-
localScore
public double localScore(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Calculates the local scoring for a given node in a Bayesian Network based on the provided parent and child configurations.- Specified by:
localScorein interfaceIsScore- Parameters:
node- The index of the node for which the score is being calculated.parents_is- An array of indices representing the context-specific parents of the node.parents_pop- An array of indices representing the population-wide parents of the node.children_pop- An array of indices representing the children of the node in the population-wide model.- Returns:
- The computed local score as a double value.
-
getParentValues
public int[] getParentValues(int nodeIndex, int rowIndex, int[] dims) Computes the parent values for a given node index and row index according to the specified dimensions.- Parameters:
nodeIndex- The index of the node for which parent values are computed.rowIndex- The row index used for computations.dims- An array representing the dimensions of the parent values.- Returns:
- An array of integers representing the computed parent values.
-
getParentValuesForCombination
public int[] getParentValuesForCombination(int rowIndex, int[] dims) Calculates the parent values for a given combination of dimensions.- Parameters:
rowIndex- the index representing the combination in a linearized formdims- an array indicating the size of each dimension- Returns:
- an array of integers where each element corresponds to the value of the dimension at that index
-
localScoreDiff
public double localScoreDiff(int x, int y, int[] z, int[] z_pop, int[] child_pop) Computes the difference in local scores when element x is appended to the array z.- Specified by:
localScoreDiffin interfaceIsScore- Parameters:
x- the element to be appended to the array zy- the dependent variable whose score is being calculatedz- the initial array of elementsz_pop- the population related to zchild_pop- the population related to the dependent variable y- Returns:
- the difference in local scores after appending x to z
-
getVariables
Retrieves the list of variables associated with this instance.- Specified by:
getVariablesin interfaceIsScore- Returns:
- a list of Node objects representing the variables
-
setVariables
Sets the list of variables after validating that each variable in the provided list has the same name as the corresponding variable in the existing list.- Parameters:
variables- a list of Node objects to be set as the new variables- Throws:
IllegalArgumentException- if any variable in the provided list does not have the same name as the variable it is replacing
-
getSampleSize
public int getSampleSize()Retrieves the current sample size.- Specified by:
getSampleSizein interfaceIsScore- Returns:
- the sample size as an integer.
-
isEffectEdge
public boolean isEffectEdge(double bump) Must be called directly after the corresponding scoring call.- Specified by:
isEffectEdgein interfaceIsScore- Parameters:
bump- The threshold value to evaluate the significance of the effect on the edge.- Returns:
- true if the edge has a significant effect; false otherwise.
-
getDataSet
Retrieves a DataSet object.- Specified by:
getDataSetin interfaceIsScore- Returns:
- a DataSet object
- Throws:
UnsupportedOperationException- if the method is not supported
-
getStructurePrior
public double getStructurePrior()Retrieves the value of the structure prior.- Specified by:
getStructurePriorin interfaceIsScore- Returns:
- the structure prior as a double.
-
setStructurePrior
public void setStructurePrior(double structurePrior) Sets the structure prior for the model.- Specified by:
setStructurePriorin interfaceIsScore- Parameters:
structurePrior- the prior value to be set, typically controlling the influence of structure in the model
-
getSamplePrior
public double getSamplePrior()Retrieves the prior value of the sample.- Specified by:
getSamplePriorin interfaceIsScore- Returns:
- the prior value of the sample as a double.
-
setSamplePrior
public void setSamplePrior(double samplePrior) Sets the value for the samplePrior field.- Specified by:
setSamplePriorin interfaceIsScore- Parameters:
samplePrior- The prior sample value to be set.
-
getKAddition
public double getKAddition()Retrieves the value of the variable representing the k_addition.- Returns:
- the current value of the k_addition variable as a double.
-
setKAddition
public void setKAddition(double k_addition) Sets the value of k_addition.- Parameters:
k_addition- The value to set for k_addition.
-
getKDeletion
public double getKDeletion()Retrieves the value of the k_deletion field.- Returns:
- the current value of k_deletion.
-
setKDeletion
public void setKDeletion(double k_deletion) Sets the value of k_deletion.- Parameters:
k_deletion- the new value to set for k_deletion
-
getKReorientation
public double getKReorientation()Retrieves the value of the k_reorient variable.- Returns:
- The value of k_reorient as a double.
-
setKReorientation
public void setKReorientation(double k_reorient) Sets the value of the K-reorientation parameter.- Parameters:
k_reorient- the new value for the K-reorientation parameter
-
getVariable
Retrieves a Node from the variables list that matches the specified target name.- Specified by:
getVariablein interfaceIsScore- Parameters:
targetName- the name of the target Node to be retrieved- Returns:
- the Node that matches the target name, or null if no match is found
-
getMaxDegree
public int getMaxDegree()Calculates the maximum degree based on the sample size.- Specified by:
getMaxDegreein interfaceIsScore- Returns:
- the maximum degree as an integer.
-
determines
Determines whether a given node y is determined by a list of nodes z.- Specified by:
determinesin interfaceIsScore- Parameters:
z- the list of nodes to be evaluatedy- the node to be checked- Returns:
- true if y is determined by the list of nodes z, false otherwise
-
localScore1
public double localScore1(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Computes the local score for a given node considering both population and context-specific parents.This function is used to score a node in a dag without using structure prior
- Specified by:
localScore1in interfaceIsScore- Parameters:
node- The index of the node for which the score is being calculated.parents_is- Array representing the indices of the context-specific parents.parents_pop- Array representing the indices of the population-based parents.children_pop- Array representing the indices of the population-based children.- Returns:
- The computed local score for the specified node.
-