Documentation of 'jsat.classifiers.bayesian.ConditionalProbabilityTable' Java class
ConditionalProbabilityTable
jsat.classifiers.bayesian

Class ConditionalProbabilityTable

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier


    public class ConditionalProbabilityTable
    extends java.lang.Object
    implements Classifier
    The conditional probability table (CPT) is a classifier for categorical attributes. It builds the whole conditional probability table for a data set. The size of the CPT grows exponentially with the number of dimensions and options, and requires exponentially more data to get a good fit. CPTs can be useful for small data sets, or as a building block for another algorithm
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      CategoricalResults classify(DataPoint data)
      Performs classification on the given data point.
      Classifier clone() 
      int dataPointToCord(DataPointPair<java.lang.Integer> dataPoint, int targetClass, int[] cord)
      Converts a data point pair into a coordinate.
      int getDimensionSize()
      Returns the number of dimensions in the CPT
      double query(int targetClass, DataPointPair<java.lang.Integer> dataPoint)
      Queries the CPT for the probability that the class value of targetClas would occur with the given DataPointPair.
      double query(int targetClass, int targetValue, int[] cord)
      Queries the CPT for the probability of the target class occurring with the specified value given the class values of the other attributes
      boolean supportsWeightedData()
      Indicates whether the model knows how to train using weighted data points.
      void train(ClassificationDataSet dataSet)
      Trains the classifier and constructs a model for classification using the given data set.
      void train(ClassificationDataSet dataSet, boolean parallel)
      Trains the classifier and constructs a model for classification using the given data set.
      void trainC(ClassificationDataSet dataSet, java.util.Set<java.lang.Integer> categoriesToUse)
      Creates a CPT using only a subset of the features specified by categoriesToUse.
      • Methods inherited from class java.lang.Object

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

      • ConditionalProbabilityTable

        public ConditionalProbabilityTable()
    • Method Detail

      • classify

        public CategoricalResults classify(DataPoint data)
        Description copied from interface: Classifier
        Performs classification on the given data point.
        Specified by:
        classify in interface Classifier
        Parameters:
        data - the data point to classify
        Returns:
        the results of the classification.
      • getDimensionSize

        public int getDimensionSize()
        Returns the number of dimensions in the CPT
        Returns:
        the number of dimensions in the CPT
      • dataPointToCord

        public int dataPointToCord(DataPointPair<java.lang.Integer> dataPoint,
                                   int targetClass,
                                   int[] cord)
        Converts a data point pair into a coordinate. The paired value contains the value for the predicting index. Though this value will not be used if the predicting class of the original data set was not used to make the table.
        Parameters:
        dataPoint - the DataPointPair to convert
        targetClass - the index in the original data set of the category that we would like to predict
        cord - the array to store the coordinate in.
        Returns:
        the value of the target class for the given data point
        Throws:
        java.lang.ArithmeticException - if the cord array does not match the dimension of the CPT
      • train

        public void train(ClassificationDataSet dataSet,
                          boolean parallel)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.
        Specified by:
        train in interface Classifier
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used to train the model. false if it should be done in a single threaded manner.
      • train

        public void train(ClassificationDataSet dataSet)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set.
        Specified by:
        train in interface Classifier
        Parameters:
        dataSet - the data set to train on
      • trainC

        public void trainC(ClassificationDataSet dataSet,
                           java.util.Set<java.lang.Integer> categoriesToUse)
        Creates a CPT using only a subset of the features specified by categoriesToUse.
        Parameters:
        dataSet - the data set to train from
        categoriesToUse - the attributes to use in training. Each value corresponds to the categorical index in dataSet, and adding the value DataSet.getNumCategoricalVars(), which is not a valid index, indicates to used the predicting class of the data set in the CPT.
      • query

        public double query(int targetClass,
                            DataPointPair<java.lang.Integer> dataPoint)
        Queries the CPT for the probability that the class value of targetClas would occur with the given DataPointPair.
        Parameters:
        targetClass - the index in the original data set of the class that we want the probability of
        dataPoint - the data point of values paired with the value of the predicting attribute in the original training set
        Returns:
        the probability in [0,1] of the target class value occurring with the given DataPointPair
      • query

        public double query(int targetClass,
                            int targetValue,
                            int[] cord)
        Queries the CPT for the probability of the target class occurring with the specified value given the class values of the other attributes
        Parameters:
        targetClass - the index in the original data set of the class that we want to probability of
        targetValue - the value of the targetClass that we want to probability of occurring
        cord - the coordinate array that corresponds the the class values for the CPT, where the coordinate of the targetClass may contain any value.
        Returns:
        the probability in [0, 1] of the targetClass occurring with the targetValue given the information in cord
        See Also:
        dataPointToCord(jsat.classifiers.DataPointPair, int, int[])
      • supportsWeightedData

        public boolean supportsWeightedData()
        Description copied from interface: Classifier
        Indicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.
        Specified by:
        supportsWeightedData in interface Classifier
        Returns:
        true if the model supports weighted data, false otherwise
      • clone

        public Classifier clone()
        Specified by:
        clone in interface Classifier
        Overrides:
        clone in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.