Class BayesUpdaterClassifier

java.lang.Object
edu.cmu.tetrad.search.BayesUpdaterClassifier
All Implemented Interfaces:
DiscreteClassifier, TetradSerializable, Serializable

public final class BayesUpdaterClassifier extends Object implements DiscreteClassifier, TetradSerializable
This class contains a method classify which uses an instantiated Bayes net (BayesIm) provided in the constructor. For each case (record) in the DataSet it uses the values of all variables but the target variable to update the distributions of all the variables. It then computes an estimated value for the target variable by selecting the value with the greatest probability in the updated distribution. The method returns a crosstabulation table in the form of a two-dimensional integer array in which coefs of observed versus estimated values of the target variable are stored. Note that the variables must be the same in the dataset and the Bayes net.
Author:
Frank Wimberly based on a specification by Clark Glymour
See Also:
  • Constructor Details

    • BayesUpdaterClassifier

      public BayesUpdaterClassifier(BayesIm bayesIm, DataSet testData)
  • Method Details

    • serializableInstance

      public static BayesUpdaterClassifier serializableInstance()
      Generates a simple exemplar of this class to test serialization.
    • setTarget

      public void setTarget(String target)
    • classify

      public int[] classify()
      Computes and returns the crosstabulation of observed versus estimated values of the target variable as described above.
      Specified by:
      classify in interface DiscreteClassifier
      Returns:
      an array with a classification (estimated value) of a target variable for each case in a DataSet.
    • crossTabulation

      public int[][] crossTabulation()
      Computes the "confusion matrix" of coefs of the number of cases associated with each combination of estimated and observed values in the test dataset. Each row, column i,j corresponds to the ith and jth categories of the target variable.
      Specified by:
      crossTabulation in interface DiscreteClassifier
      Returns:
      an int[][] array containing the coefs, or null if the target variable is not in the test data.
    • getPercentCorrect

      public double getPercentCorrect()
      Specified by:
      getPercentCorrect in interface DiscreteClassifier
      Returns:
      the percentage of cases in which the target variable is correctly classified.
    • getTargetVariable

      public DiscreteVariable getTargetVariable()
      Returns:
      the DiscreteVariable which is the target variable.
    • getBayesIm

      public BayesIm getBayesIm()
    • getTestData

      public DataSet getTestData()
    • getClassifications

      public int[] getClassifications()
    • getMarginals

      public double[][] getMarginals()
    • getNumCases

      public int getNumCases()
    • getTotalUsableCases

      public int getTotalUsableCases()
    • getBayesImVars

      public List<Node> getBayesImVars()