Class ISBicScore
java.lang.Object
edu.cmu.tetrad.search.work_in_progress.ISBicScore
-
Constructor Summary
ConstructorsConstructorDescriptionISBicScore
(DataSet dataSet, DataSet testCase) Constructs an ISBicScore instance with the provided data sets. -
Method Summary
Modifier and TypeMethodDescriptionboolean
determines
(List<Node> z, Node y) Determines if the given list of nodes can determine the specified node.Retrieves the data set from the current context.double
Retrieves the current value of the k_addition parameter.double
Retrieves the current value of the k_deletion parameter.double
Retrieves the current value of the k_reorientation parameter.int
Retrieves the maximum degree value.int[]
getParentValues
(int nodeIndex, int rowIndex, int[] dims) Calculates the parent values at given node and row indices based on the provided dimensions.int[]
getParentValuesForCombination
(int rowIndex, int[] dims) Calculates the parent values for a given row index based on the provided dimensions.double
Retrieves the penalty discount associated with this entity.double
Calculates and returns the sample prior value.int
Retrieves the current sample size.double
Retrieves the prior probability of the given structure.getVariable
(String targetName) Retrieves a Node from the variables list that matches the specified target name.Retrieves the list of variables associated with this ISBicScore instance.boolean
isEffectEdge
(double bump) Must be called directly after the corresponding scoring call.double
localScore
(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Calculates the local score for a given node considering its parents.double
localScore1
(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Computes a local score based on the given node, its parents, and its children's populations.double
localScoreDiff
(int x, int y, int[] z, int[] z_pop, int[] child_pop) Calculates the difference in local scores for a given variable when it is added to or removed from a set of parent variables.void
setPenaltyDiscount
(double penaltyDiscount) Sets the penalty discount.void
setSamplePrior
(double samplePrior) Sets the value of the sample prior.void
setStructurePrior
(double structurePrior) Sets the structure prior value for the current configuration.void
setVariables
(List<Node> variables) Sets the list of variables for the instance.
-
Constructor Details
-
ISBicScore
Constructs an ISBicScore instance with the provided data sets.- Parameters:
dataSet
- The primary DataSet instance for training, must not be null.testCase
- The test DataSet instance used for validation or testing.- Throws:
NullPointerException
- if dataSet is null.IllegalArgumentException
- if dataBox within dataSet is not an instance of VerticalIntDataBox.
-
-
Method Details
-
localScore
public double localScore(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Calculates the local score for a given node considering its parents.- Specified by:
localScore
in interfaceISScore
- Parameters:
node
- The index of the node to calculate the score for.parents_is
- Array of indices representing the parents of the node in the IS model.parents_pop
- Array of indices representing the parents of the node in the POP model.children_pop
- Array of indices representing the children of the node in the POP model.- Returns:
- The local score for the given node.
-
localScoreDiff
public double localScoreDiff(int x, int y, int[] z, int[] z_pop, int[] child_pop) Calculates the difference in local scores for a given variable when it is added to or removed from a set of parent variables.- Specified by:
localScoreDiff
in interfaceISScore
- Parameters:
x
- The variable to be added or removed.y
- The target variable whose score is being calculated.z
- The set of parent variables excluding the variable x.z_pop
- The set of population parent variables excluding the variable x.child_pop
- The set of population children variables.- Returns:
- The difference in local scores after adding/removing the variable x.
-
getParentValues
public int[] getParentValues(int nodeIndex, int rowIndex, int[] dims) Calculates the parent values at given node and row indices based on the provided dimensions.- Parameters:
nodeIndex
- The index of the node for which parent values are being calculated.rowIndex
- The row index that needs to be converted to parent values.dims
- An array representing the dimensions of the parents.- Returns:
- An array of integers where each value corresponds to a parent value at the given row index.
-
getParentValuesForCombination
public int[] getParentValuesForCombination(int rowIndex, int[] dims) Calculates the parent values for a given row index based on the provided dimensions.- Parameters:
rowIndex
- The row index that needs to be converted to parent values.dims
- An array representing the dimensions of the parents.- Returns:
- An array of integers where each value corresponds to a parent value at the given row index.
-
getKAddition
public double getKAddition()Retrieves the current value of the k_addition parameter.- Returns:
- The value of the k_addition parameter.
-
getKDeletion
public double getKDeletion()Retrieves the current value of the k_deletion parameter.- Returns:
- The value of the k_deletion parameter.
-
getKReorientation
public double getKReorientation()Retrieves the current value of the k_reorientation parameter.- Returns:
- The value of the k_reorientation parameter.
-
getVariables
Retrieves the list of variables associated with this ISBicScore instance.- Specified by:
getVariables
in interfaceISScore
- Returns:
- a List of Node objects representing the variables.
-
setVariables
Sets the list of variables for the instance. All nodes in the new list must have the same names as the corresponding nodes in the existing list.- Parameters:
variables
- the new list of variables to set- Throws:
IllegalArgumentException
- if any variable in the new list has a different name from the corresponding variable in the existing list
-
getSampleSize
public int getSampleSize()Retrieves the current sample size.- Specified by:
getSampleSize
in 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:
isEffectEdge
in 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 the data set from the current context.- Specified by:
getDataSet
in interfaceISScore
- Returns:
- DataSet object containing the data.
- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
getStructurePrior
public double getStructurePrior()Retrieves the prior probability of the given structure.- Specified by:
getStructurePrior
in interfaceISScore
- Returns:
- the prior probability of the structure as a double.
- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
setStructurePrior
public void setStructurePrior(double structurePrior) Sets the structure prior value for the current configuration.- Specified by:
setStructurePrior
in interfaceISScore
- Parameters:
structurePrior
- the value to be set as the structure prior.
-
getSamplePrior
public double getSamplePrior()Calculates and returns the sample prior value.- Specified by:
getSamplePrior
in interfaceISScore
- Returns:
- The sample prior value as a double.
- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
setSamplePrior
public void setSamplePrior(double samplePrior) Sets the value of the sample prior.- Specified by:
setSamplePrior
in interfaceISScore
- Parameters:
samplePrior
- The value to be set as the sample prior.- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
getPenaltyDiscount
public double getPenaltyDiscount()Retrieves the penalty discount associated with this entity.- Returns:
- the penalty discount as a double
-
setPenaltyDiscount
public void setPenaltyDiscount(double penaltyDiscount) Sets the penalty discount.- Parameters:
penaltyDiscount
- The discount to be applied as a penalty, represented as a decimal.
-
getVariable
Retrieves a Node from the variables list that matches the specified target name.- Specified by:
getVariable
in interfaceISScore
- Parameters:
targetName
- the name of the variable to search for- Returns:
- the Node that matches the target name, or null if no match is found
-
getMaxDegree
public int getMaxDegree()Retrieves the maximum degree value.- Specified by:
getMaxDegree
in interfaceISScore
- Returns:
- the maximum degree, which is a constant value of 1000.
-
determines
Determines if the given list of nodes can determine the specified node.- Specified by:
determines
in interfaceISScore
- Parameters:
z
- the list of nodes that are tested to determine the node yy
- the node whose determination is being tested- Returns:
- true if the list of nodes z can determine the node y, otherwise false
-
localScore1
public double localScore1(int node, int[] parents_is, int[] parents_pop, int[] children_pop) Computes a local score based on the given node, its parents, and its children's populations.- Specified by:
localScore1
in interfaceISScore
- Parameters:
node
- an integer representing the current node for which the score is being computedparents_is
- an array of integers representing the indices of a node's parentsparents_pop
- an array of integers representing the population of each parentchildren_pop
- an array of integers representing the population of each child- Returns:
- a double representing the computed local score
-