Class ClassifierBayesUpdaterDiscrete

java.lang.Object
edu.cmu.tetrad.classify.ClassifierBayesUpdaterDiscrete
All Implemented Interfaces:
ClassifierDiscrete, TetradSerializable, Serializable

public final class ClassifierBayesUpdaterDiscrete extends Object implements ClassifierDiscrete, 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

    • ClassifierBayesUpdaterDiscrete

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

    • serializableInstance

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

      public void setTarget(String target)
      Sets the target variable.
      Parameters:
      target - This variable.
    • classify

      public int[] classify()
      Computes and returns the cross-tabulation of observed versus estimated values of the target variable as described above.
      Specified by:
      classify in interface ClassifierDiscrete
      Returns:
      this cross-tabulation.
    • 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 ClassifierDiscrete
      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 ClassifierDiscrete
      Returns:
      the percentage of cases in which the target variable is correctly classified.
    • getTargetVariable

      public DiscreteVariable getTargetVariable()
      Returns:
      the discrete variables which is the target variable.
      See Also:
    • getBayesIm

      public BayesIm getBayesIm()
      Returns the Bayes IM being used.
      Returns:
      This IM
      See Also:
    • getTestData

      public DataSet getTestData()
      Returns the test data being used.
      Returns:
      This data.
    • getClassifications

      public int[] getClassifications()
      Returns the classification for the target variable.
      Returns:
      Thsi classification.
    • getMarginals

      public double[][] getMarginals()
      Returns the marginals.
      Returns:
      This.
    • getNumCases

      public int getNumCases()
      Returns the number of cases for the data.
      Returns:
      This number.
    • getTotalUsableCases

      public int getTotalUsableCases()
      Returns the number of usable cases for the data.
      Returns:
      Thsi number.
    • getBayesImVars

      public List<Node> getBayesImVars()
      Returns the variables of the BayesIM.
      Returns:
      These variables as a list.
      See Also: