public class Distribution extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, RevisionHandler
Constructor and Description |
---|
Distribution(Distribution toMerge)
Creates distribution with only one bag by merging all bags of given
distribution.
|
Distribution(Distribution toMerge,
int index)
Creates distribution with two bags by merging all bags apart of the
indicated one.
|
Distribution(double[][] table)
Creates and initializes a new distribution using the given array.
|
Distribution(Instances source)
Creates a distribution with only one bag according to instances in source.
|
Distribution(Instances source,
ClassifierSplitModel modelToUse)
Creates a distribution according to given instances and split model.
|
Distribution(int numBags,
int numClasses)
Creates and initializes a new distribution.
|
Modifier and Type | Method and Description |
---|---|
int |
actualNumBags()
Returns number of non-empty bags of distribution.
|
int |
actualNumClasses()
Returns number of classes actually occuring in distribution.
|
int |
actualNumClasses(int bagIndex)
Returns number of classes actually occuring in given bag.
|
void |
add(int bagIndex,
double[] counts)
Adds counts to given bag.
|
void |
add(int bagIndex,
Instance instance)
Adds given instance to given bag.
|
void |
addInstWithUnknown(Instances source,
int attIndex)
Adds all instances with unknown values for given attribute, weighted
according to frequency of instances in each bag.
|
void |
addRange(int bagIndex,
Instances source,
int startIndex,
int lastPlusOne)
Adds all instances in given range to given bag.
|
void |
addWeights(Instance instance,
double[] weights)
Adds given instance to all bags weighting it according to given weights.
|
boolean |
check(double minNoObj)
Checks if at least two bags contain a minimum number of instances.
|
java.lang.Object |
clone()
Clones distribution (Deep copy of distribution).
|
void |
del(int bagIndex,
Instance instance)
Deletes given instance from given bag.
|
void |
delRange(int bagIndex,
Instances source,
int startIndex,
int lastPlusOne)
Deletes all instances in given range from given bag.
|
java.lang.String |
dumpDistribution()
Prints distribution.
|
java.lang.String |
getRevision()
Returns the revision string.
|
void |
initialize()
Sets all counts to zero.
|
double |
laplaceProb(int classIndex)
Returns relative frequency of class over all bags with Laplace correction.
|
double |
laplaceProb(int classIndex,
int intIndex)
Returns relative frequency of class for given bag.
|
double[][] |
matrix()
Returns matrix with distribution of class values.
|
int |
maxBag()
Returns index of bag containing maximum number of instances.
|
int |
maxClass()
Returns class with highest frequency over all bags.
|
int |
maxClass(int index)
Returns class with highest frequency for given bag.
|
int |
numBags()
Returns number of bags.
|
int |
numClasses()
Returns number of classes.
|
double |
numCorrect()
Returns perClass(maxClass()).
|
double |
numCorrect(int index)
Returns perClassPerBag(index,maxClass(index)).
|
double |
numIncorrect()
Returns total-numCorrect().
|
double |
numIncorrect(int index)
Returns perBag(index)-numCorrect(index).
|
double |
perBag(int bagIndex)
Returns number of (possibly fractional) instances in given bag.
|
double |
perClass(int classIndex)
Returns number of (possibly fractional) instances of given class.
|
double |
perClassPerBag(int bagIndex,
int classIndex)
Returns number of (possibly fractional) instances of given class in given
bag.
|
double |
prob(int classIndex)
Returns relative frequency of class over all bags.
|
double |
prob(int classIndex,
int intIndex)
Returns relative frequency of class for given bag.
|
void |
shift(int from,
int to,
Instance instance)
Shifts given instance from one bag to another one.
|
void |
shiftRange(int from,
int to,
Instances source,
int startIndex,
int lastPlusOne)
Shifts all instances in given range from one bag to another one.
|
void |
sub(int bagIndex,
Instance instance)
Subtracts given instance from given bag.
|
Distribution |
subtract(Distribution toSubstract)
Subtracts the given distribution from this one.
|
double |
total()
Returns total number of (possibly fractional) instances.
|
public Distribution(int numBags, int numClasses)
public Distribution(double[][] table)
public Distribution(Instances source) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic Distribution(Instances source, ClassifierSplitModel modelToUse) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic Distribution(Distribution toMerge)
public Distribution(Distribution toMerge, int index)
public final int actualNumBags()
public final int actualNumClasses()
public final int actualNumClasses(int bagIndex)
public final void add(int bagIndex, Instance instance) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void sub(int bagIndex, Instance instance) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void add(int bagIndex, double[] counts)
public final void addInstWithUnknown(Instances source, int attIndex) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void addRange(int bagIndex, Instances source, int startIndex, int lastPlusOne) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void addWeights(Instance instance, double[] weights) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final boolean check(double minNoObj)
public final java.lang.Object clone()
clone
in class java.lang.Object
public final void del(int bagIndex, Instance instance) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void delRange(int bagIndex, Instances source, int startIndex, int lastPlusOne) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final java.lang.String dumpDistribution()
public final void initialize()
public final double[][] matrix()
public final int maxBag()
public final int maxClass()
public final int maxClass(int index)
public final int numBags()
public final int numClasses()
public final double numCorrect()
public final double numCorrect(int index)
public final double numIncorrect()
public final double numIncorrect(int index)
public final double perClassPerBag(int bagIndex, int classIndex)
public final double perBag(int bagIndex)
public final double perClass(int classIndex)
public final double laplaceProb(int classIndex)
public final double laplaceProb(int classIndex, int intIndex)
public final double prob(int classIndex)
public final double prob(int classIndex, int intIndex)
public final Distribution subtract(Distribution toSubstract)
public final double total()
public final void shift(int from, int to, Instance instance) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic final void shiftRange(int from, int to, Instances source, int startIndex, int lastPlusOne) throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler