Class ISBicScore

java.lang.Object
edu.cmu.tetrad.search.work_in_progress.ISBicScore
All Implemented Interfaces:
ISScore

public class ISBicScore extends Object implements ISScore
A class representing the ISBicScore, which calculates BIC scores for a Bayesian network considering different structural changes and their impacts using an information-sharing mechanism.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ISBicScore(DataSet dataSet, DataSet testCase)
    Constructs an ISBicScore instance with the provided data sets.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    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.

    Methods inherited from class java.lang.Object

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

    • ISBicScore

      public ISBicScore(DataSet dataSet, DataSet testCase)
      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 interface ISScore
      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 interface ISScore
      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

      public List<Node> getVariables()
      Retrieves the list of variables associated with this ISBicScore 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 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 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 the data set from the current context.
      Specified by:
      getDataSet in interface ISScore
      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 interface ISScore
      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 interface ISScore
      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 interface ISScore
      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 interface ISScore
      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

      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 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 interface ISScore
      Returns:
      the maximum degree, which is a constant value of 1000.
    • determines

      public boolean determines(List<Node> z, Node y)
      Determines if the given list of nodes can determine the specified node.
      Specified by:
      determines in interface ISScore
      Parameters:
      z - the list of nodes that are tested to determine the node y
      y - 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 interface ISScore
      Parameters:
      node - an integer representing the current node for which the score is being computed
      parents_is - an array of integers representing the indices of a node's parents
      parents_pop - an array of integers representing the population of each parent
      children_pop - an array of integers representing the population of each child
      Returns:
      a double representing the computed local score