Class IsBDeuScore

java.lang.Object
edu.cmu.tetrad.search.score.IsBDeuScore
All Implemented Interfaces:
Score

public final class IsBDeuScore extends Object implements Score
Instance-Specific BDeu score (discrete), following the Dirichlet–multinomial posterior predictive for the chosen instance (Fattaneh's construction).

Local score: IS-local(i | Pa) = BDeu-local(i | Pa) + alpha * log P_instance

where the instance term is: log P_instance = log( (N_ijk + ESS/(r_i q)) / (N_ij + ESS/q) ) - i: child index - Pa: parents' indices - j: parent configuration index of the instance row - k: categorical value of X_i in the instance row - r_i: number of categories for X_i - q: number of distinct parent configurations (product of parent arities) - N_ijk, N_ij: counts from the training data (ignoring rows with missing in i or Pa)

Missing values: if the instance row has missing for i or any parent, the instance term is 0.

Assumes the instance DataSet is a single row, already aligned to the training schema (same variable names and category label sets).

  • Constructor Summary

    Constructors
    Constructor
    Description
    IsBDeuScore(DataSet train, DataSet instanceOneRow)
    Constructs an IsBDeuScore object that validates and initializes a training dataset and a single-instance dataset for Bayesian scoring.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Retrieves the value of the isAlpha field.
    double
    Retrieves the prior equivalent sample size used for Bayesian scoring.
    int
    Retrieves the sample size of the data by delegating to the underlying base implementation.
    Retrieves the list of variables (nodes) associated with the model or scoring process.
    double
    localScore(int i)
    Computes the local score for a given node in the graph, incorporating both the base score and an instance-specific term weighted by the isAlpha parameter.
    double
    localScore(int i, int[] parents)
    Computes the local score for a given node and its parents by combining the base local score and an instance-specific term influenced by the isAlpha parameter.
    void
    setIsAlpha(double isAlpha)
    Sets the value of the isAlpha field.
    void
    Sets the prior equivalent sample size to be used for Bayesian scoring.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface edu.cmu.tetrad.search.score.Score

    append, determines, getMaxDegree, getVariable, isEffectEdge, localScore, localScoreDiff, localScoreDiff, toString
  • Constructor Details

    • IsBDeuScore

      public IsBDeuScore(DataSet train, DataSet instanceOneRow)
      Constructs an IsBDeuScore object that validates and initializes a training dataset and a single-instance dataset for Bayesian scoring. The training and instance datasets must be discrete and share the same schema, including variable names and categories.
      Parameters:
      train - the training dataset, which must be discrete and contain the variables for scoring. It must have the same schema as the instance dataset.
      instanceOneRow - the single-instance dataset with exactly one row, which must be discrete. Its schema (variable names and categories) must align with the training dataset.
      Throws:
      NullPointerException - if the training dataset or instance dataset is null.
      IllegalArgumentException - if the training dataset is not discrete, if the instance dataset is not discrete or does not have exactly one row, if the number of columns in the training dataset and the instance dataset differ, or if variable names and categories in the datasets do not align.
  • Method Details

    • getIsAlpha

      public double getIsAlpha()
      Retrieves the value of the isAlpha field.
      Returns:
      the current value of the isAlpha field as a double.
    • setIsAlpha

      public void setIsAlpha(double isAlpha)
      Sets the value of the isAlpha field.
      Parameters:
      isAlpha - the new value to be assigned to the isAlpha field.
    • getPriorEquivalentSampleSize

      public double getPriorEquivalentSampleSize()
      Retrieves the prior equivalent sample size used for Bayesian scoring. This value represents an effective sample size proxy that influences the score computation.
      Returns:
      the prior equivalent sample size as a double.
    • setPriorEquivalentSampleSize

      public void setPriorEquivalentSampleSize(double ess)
      Sets the prior equivalent sample size to be used for Bayesian scoring. This value serves as an effective sample size proxy that influences the computations within the scoring process.
      Parameters:
      ess - the prior equivalent sample size to be set, typically a positive double value. It controls the relative strength of the prior in Bayesian score calculations.
    • getVariables

      public List<Node> getVariables()
      Retrieves the list of variables (nodes) associated with the model or scoring process.
      Specified by:
      getVariables in interface Score
      Returns:
      a list of Node objects representing the variables, as obtained from the underlying base implementation.
    • getSampleSize

      public int getSampleSize()
      Retrieves the sample size of the data by delegating to the underlying base implementation.
      Specified by:
      getSampleSize in interface Score
      Returns:
      the sample size of the data as an integer.
    • localScore

      public double localScore(int i)
      Computes the local score for a given node in the graph, incorporating both the base score and an instance-specific term weighted by the isAlpha parameter.
      Specified by:
      localScore in interface Score
      Parameters:
      i - the index of the node for which the local score is computed.
      Returns:
      the computed local score, which combines the base score and the instance-specific contribution.
    • localScore

      public double localScore(int i, int[] parents)
      Computes the local score for a given node and its parents by combining the base local score and an instance-specific term influenced by the isAlpha parameter.
      Specified by:
      localScore in interface Score
      Parameters:
      i - the index of the node for which the local score is being computed.
      parents - an array of node indices representing the parents of the node.
      Returns:
      the local score calculated as the sum of the base score and the instance-specific term weighted by the isAlpha parameter.