All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.j48.Distribution

java.lang.Object
    |
    +----weka.classifiers.j48.Distribution

public class Distribution
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Class for handling a distribution of class values.

Version:
$Revision: 1.6 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)

Constructor Index

 o Distribution(Distribution)
Creates distribution with only one bag by merging all bags of given distribution.
 o Distribution(Distribution, int)
Creates distribution with two bags by merging all bags apart of the indicated one.
 o Distribution(double[][])
Creates and initializes a new distribution using the given array.
 o Distribution(Instances)
Creates a distribution with only one bag according to instances in source.
 o Distribution(Instances, ClassifierSplitModel)
Creates a distribution according to given instances and split model.
 o Distribution(int, int)
Creates and initializes a new distribution.

Method Index

 o actualNumBags()
Returns number of non-empty bags of distribution.
 o actualNumClasses()
Returns number of classes actually occuring in distribution.
 o actualNumClasses(int)
Returns number of classes actually occuring in given bag.
 o add(int, double[])
Adds counts to given bag.
 o add(int, Instance)
Adds given instance to given bag.
 o addInstWithUnknown(Instances, int)
Adds all instances with unknown values for given attribute, weighted according to frequency of instances in each bag.
 o addRange(int, Instances, int, int)
Adds all instances in given range to given bag.
 o addWeights(Instance, double[])
Adds given instance to all bags weighting it according to given weights.
 o check(double)
Checks if at least two bags contain a minimum number of instances.
 o clone()
Clones distribution (Deep copy of distribution).
 o del(int, Instance)
Deletes given instance from given bag.
 o delRange(int, Instances, int, int)
Deletes all instances in given range from given bag.
 o dumpDistribution()
Prints distribution.
 o initialize()
Sets all counts to zero.
 o laplaceProb(int)
Returns relative frequency of class over all bags with Laplace correction.
 o laplaceProb(int, int)
Returns relative frequency of class for given bag.
 o matrix()
Returns matrix with distribution of class values.
 o maxBag()
Returns index of bag containing maximum number of instances.
 o maxClass()
Returns class with highest frequency over all bags.
 o maxClass(int)
Returns class with highest frequency for given bag.
 o numBags()
Returns number of bags.
 o numClasses()
Returns number of classes.
 o numCorrect()
Returns perClass(maxClass()).
 o numCorrect(int)
Returns perClassPerBag(index,maxClass(index)).
 o numIncorrect()
Returns total-numCorrect().
 o numIncorrect(int)
Returns perBag(index)-numCorrect(index).
 o perBag(int)
Returns number of (possibly fractional) instances in given bag.
 o perClass(int)
Returns number of (possibly fractional) instances of given class.
 o perClassPerBag(int, int)
Returns number of (possibly fractional) instances of given class in given bag.
 o prob(int)
Returns relative frequency of class over all bags.
 o prob(int, int)
Returns relative frequency of class for given bag.
 o shift(int, int, Instance)
Shifts given instance from one bag to another one.
 o shiftRange(int, int, Instances, int, int)
Shifts all instances in given range from one bag to another one.
 o sub(int, Instance)
Subtracts given instance from given bag.
 o subtract(Distribution)
Subtracts the given distribution from this one.
 o total()
Returns total number of (possibly fractional) instances.

Constructor Detail

 o Distribution
public Distribution(int numBags,
                    int numClasses)
          Creates and initializes a new distribution.
 o Distribution
public Distribution(double table[][])
          Creates and initializes a new distribution using the given array. WARNING: it just copies a reference to this array.
 o Distribution
public Distribution(Instances source) throws java.lang.Exception
          Creates a distribution with only one bag according to instances in source.
Throws:
java.lang.Exception - if something goes wrong
 o Distribution
public Distribution(Instances source,
                    ClassifierSplitModel modelToUse) throws java.lang.Exception
          Creates a distribution according to given instances and split model.
Throws:
java.lang.Exception - if something goes wrong
 o Distribution
public Distribution(Distribution toMerge)
          Creates distribution with only one bag by merging all bags of given distribution.
 o Distribution
public Distribution(Distribution toMerge,
                    int index)
          Creates distribution with two bags by merging all bags apart of the indicated one.

Method Detail

 o actualNumBags
public final int actualNumBags()
          Returns number of non-empty bags of distribution.
 o actualNumClasses
public final int actualNumClasses()
          Returns number of classes actually occuring in distribution.
 o actualNumClasses
public final int actualNumClasses(int bagIndex)
          Returns number of classes actually occuring in given bag.
 o add
public final void add(int bagIndex,
                      Instance instance) throws java.lang.Exception
          Adds given instance to given bag.
Throws:
java.lang.Exception - if something goes wrong
 o sub
public final void sub(int bagIndex,
                      Instance instance) throws java.lang.Exception
          Subtracts given instance from given bag.
Throws:
java.lang.Exception - if something goes wrong
 o add
public final void add(int bagIndex,
                      double counts[])
          Adds counts to given bag.
 o addInstWithUnknown
public final void addInstWithUnknown(Instances source,
                                     int attIndex) throws java.lang.Exception
          Adds all instances with unknown values for given attribute, weighted according to frequency of instances in each bag.
Throws:
java.lang.Exception - if something goes wrong
 o addRange
public final void addRange(int bagIndex,
                           Instances source,
                           int startIndex,
                           int lastPlusOne) throws java.lang.Exception
          Adds all instances in given range to given bag.
Throws:
java.lang.Exception - if something goes wrong
 o addWeights
public final void addWeights(Instance instance,
                             double weights[]) throws java.lang.Exception
          Adds given instance to all bags weighting it according to given weights.
Throws:
java.lang.Exception - if something goes wrong
 o check
public final boolean check(double minNoObj)
          Checks if at least two bags contain a minimum number of instances.
 o clone
public final java.lang.Object clone()
          Clones distribution (Deep copy of distribution).
 o del
public final void del(int bagIndex,
                      Instance instance) throws java.lang.Exception
          Deletes given instance from given bag.
Throws:
java.lang.Exception - if something goes wrong
 o delRange
public final void delRange(int bagIndex,
                           Instances source,
                           int startIndex,
                           int lastPlusOne) throws java.lang.Exception
          Deletes all instances in given range from given bag.
Throws:
java.lang.Exception - if something goes wrong
 o dumpDistribution
public final java.lang.String dumpDistribution()
          Prints distribution.
 o initialize
public final void initialize()
          Sets all counts to zero.
 o matrix
public final double[][] matrix()
          Returns matrix with distribution of class values.
 o maxBag
public final int maxBag()
          Returns index of bag containing maximum number of instances.
 o maxClass
public final int maxClass()
          Returns class with highest frequency over all bags.
 o maxClass
public final int maxClass(int index)
          Returns class with highest frequency for given bag.
 o numBags
public final int numBags()
          Returns number of bags.
 o numClasses
public final int numClasses()
          Returns number of classes.
 o numCorrect
public final double numCorrect()
          Returns perClass(maxClass()).
 o numCorrect
public final double numCorrect(int index)
          Returns perClassPerBag(index,maxClass(index)).
 o numIncorrect
public final double numIncorrect()
          Returns total-numCorrect().
 o numIncorrect
public final double numIncorrect(int index)
          Returns perBag(index)-numCorrect(index).
 o perClassPerBag
public final double perClassPerBag(int bagIndex,
                                   int classIndex)
          Returns number of (possibly fractional) instances of given class in given bag.
 o perBag
public final double perBag(int bagIndex)
          Returns number of (possibly fractional) instances in given bag.
 o perClass
public final double perClass(int classIndex)
          Returns number of (possibly fractional) instances of given class.
 o laplaceProb
public final double laplaceProb(int classIndex)
          Returns relative frequency of class over all bags with Laplace correction.
 o laplaceProb
public final double laplaceProb(int classIndex,
                                int intIndex)
          Returns relative frequency of class for given bag.
 o prob
public final double prob(int classIndex)
          Returns relative frequency of class over all bags.
 o prob
public final double prob(int classIndex,
                         int intIndex)
          Returns relative frequency of class for given bag.
 o subtract
public final Distribution subtract(Distribution toSubstract)
          Subtracts the given distribution from this one. The results has only one bag.
 o total
public final double total()
          Returns total number of (possibly fractional) instances.
 o shift
public final void shift(int from,
                        int to,
                        Instance instance) throws java.lang.Exception
          Shifts given instance from one bag to another one.
Throws:
java.lang.Exception - if something goes wrong
 o shiftRange
public final void shiftRange(int from,
                             int to,
                             Instances source,
                             int startIndex,
                             int lastPlusOne) throws java.lang.Exception
          Shifts all instances in given range from one bag to another one.
Throws:
java.lang.Exception - if something goes wrong

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home