Class IsBDeuScore

java.lang.Object
edu.cmu.tetrad.search.work_in_progress.IsBDeuScore
All Implemented Interfaces:
IsScore

public class IsBDeuScore extends Object implements IsScore
Instance-Specific BDeu (IS-BDeu) score.

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

    Constructors
    Constructor
    Description
    IsBDeuScore(DataSet dataSet, DataSet testCase)
    Initializes the ISBDeuScore with the given dataset and test case.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether a given node y is determined by a list of nodes z.
    Retrieves a DataSet object.
    double
    Retrieves the value of the variable representing the k_addition.
    double
    Retrieves the value of the k_deletion field.
    double
    Retrieves the value of the k_reorient variable.
    int
    Calculates 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.
    double
    Retrieves the prior value of the sample.
    int
    Retrieves the current sample size.
    double
    Retrieves 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.
    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 scoring for a given node in a Bayesian Network based on the provided parent and child configurations.
    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.
    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.
    void
    setKAddition(double k_addition)
    Sets the value of k_addition.
    void
    setKDeletion(double k_deletion)
    Sets the value of k_deletion.
    void
    setKReorientation(double k_reorient)
    Sets the value of the K-reorientation parameter.
    void
    setSamplePrior(double samplePrior)
    Sets the value for the samplePrior field.
    void
    setStructurePrior(double structurePrior)
    Sets the structure prior for the model.
    void
    setVariables(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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IsBDeuScore

      public IsBDeuScore(DataSet dataSet, DataSet testCase)
      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:
      localScore in interface IsScore
      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 form
      dims - 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:
      localScoreDiff in interface IsScore
      Parameters:
      x - the element to be appended to the array z
      y - the dependent variable whose score is being calculated
      z - the initial array of elements
      z_pop - the population related to z
      child_pop - the population related to the dependent variable y
      Returns:
      the difference in local scores after appending x to z
    • getVariables

      public List<Node> getVariables()
      Retrieves the list of variables associated with this instance.
      Specified by:
      getVariables in interface IsScore
      Returns:
      a list of Node objects representing the variables
    • setVariables

      public void setVariables(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.
      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:
      getSampleSize in interface IsScore
      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 interface IsScore
      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

      public DataSet getDataSet()
      Retrieves a DataSet object.
      Specified by:
      getDataSet in interface IsScore
      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:
      getStructurePrior in interface IsScore
      Returns:
      the structure prior as a double.
    • setStructurePrior

      public void setStructurePrior(double structurePrior)
      Sets the structure prior for the model.
      Specified by:
      setStructurePrior in interface IsScore
      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:
      getSamplePrior in interface IsScore
      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:
      setSamplePrior in interface IsScore
      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

      public Node getVariable(String targetName)
      Retrieves a Node from the variables list that matches the specified target name.
      Specified by:
      getVariable in interface IsScore
      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:
      getMaxDegree in interface IsScore
      Returns:
      the maximum degree as an integer.
    • determines

      public boolean determines(List<Node> z, Node y)
      Determines whether a given node y is determined by a list of nodes z.
      Specified by:
      determines in interface IsScore
      Parameters:
      z - the list of nodes to be evaluated
      y - 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:
      localScore1 in interface IsScore
      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.