Package edu.cmu.tetrad.search
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]
classify()
Computes and returns the crosstabulation of observed versus estimated values of the target variable as described above.int[][]
Computes the "confusion matrix" of coefs of the number of cases associated with each combination of estimated and observed values in the test dataset.int[]
double[][]
int
double
int
static BayesUpdaterClassifier
Generates a simple exemplar of this class to test serialization.void
-
Constructor Details
-
BayesUpdaterClassifier
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
setTarget
-
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 interfaceDiscreteClassifier
- 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 interfaceDiscreteClassifier
- 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 interfaceDiscreteClassifier
- Returns:
- the percentage of cases in which the target variable is correctly classified.
-
getTargetVariable
- Returns:
- the DiscreteVariable which is the target variable.
-
getBayesIm
-
getTestData
-
getClassifications
public int[] getClassifications() -
getMarginals
public double[][] getMarginals() -
getNumCases
public int getNumCases() -
getTotalUsableCases
public int getTotalUsableCases() -
getBayesImVars
-