public class PriorEstimation extends java.lang.Object implements java.io.Serializable, RevisionHandler
Constructor and Description |
---|
PriorEstimation(Instances instances,
int numRules,
int numIntervals,
boolean car)
Constructor
|
Modifier and Type | Method and Description |
---|---|
RuleItem |
addCons(int[] itemArray)
generates a class association rule out of a given premise.
|
void |
buildDistribution(double conf,
double length)
updates the distribution of the confidence values.
|
double |
calculatePriorSum(boolean weighted,
double mPoint)
calculates the numerator and the denominator of the prior equation
|
java.util.Hashtable |
estimatePrior()
Method to estimate the prior probabilities
|
double |
findIntervall(double conf)
searches the mid point of the interval a given confidence value falls into
|
void |
generateDistribution()
Calculates the prior distribution.
|
double[] |
getMidPoints()
returns an ordered array of all mid points
|
java.lang.String |
getRevision()
Returns the revision string.
|
static double |
logbinomialCoefficient(int upperIndex,
int lowerIndex)
Method that calculates the base 2 logarithm of a binomial coefficient
|
double |
midPoint(double size,
int number)
calculates the mid point of an interval
|
void |
midPoints()
split the interval [0,1] into a predefined number of intervals and calculates their mid points
|
int[] |
randomCARule(int maxLength,
int actualLength,
java.util.Random randNum)
Constructs an item set of certain length randomly.
|
int[] |
randomRule(int maxLength,
int actualLength,
java.util.Random randNum)
Constructs an item set of certain length randomly.
|
RuleItem |
splitItemSet(int premiseLength,
int[] itemArray)
splits an item set into premise and consequence and constructs therefore
an association rule.
|
void |
updateCounters(ItemSet itemSet)
updates the support count of an item set
|
public PriorEstimation(Instances instances, int numRules, int numIntervals, boolean car)
instances
- the instances to be used for generating the associationsnumRules
- the number of random rules used for generating the priornumIntervals
- the number of intervals to discretise [0,1]car
- flag indicating whether standard or class association rules are minedpublic final void generateDistribution() throws java.lang.Exception
java.lang.Exception
- if prior can't be estimated successfullypublic final int[] randomRule(int maxLength, int actualLength, java.util.Random randNum)
maxLength
- the number of attributes of the instancesactualLength
- the number of attributes that should be present in the item setrandNum
- the random number generatorpublic final int[] randomCARule(int maxLength, int actualLength, java.util.Random randNum)
maxLength
- the number of attributes of the instancesactualLength
- the number of attributes that should be present in the item setrandNum
- the random number generatorpublic final void buildDistribution(double conf, double length)
conf
- the confidence of the randomly created rulelength
- the legnth of the randomly created rulepublic final double findIntervall(double conf)
conf
- the confidence of a rulepublic final double calculatePriorSum(boolean weighted, double mPoint)
weighted
- indicates whether the numerator or the denominator is calculatedmPoint
- the mid Point of an intervalpublic static final double logbinomialCoefficient(int upperIndex, int lowerIndex)
upperIndex
- upper Inedx of the binomial coefficientlowerIndex
- lower index of the binomial coefficientpublic final java.util.Hashtable estimatePrior() throws java.lang.Exception
java.lang.Exception
- throws exception if the prior cannot be calculatedpublic final void midPoints()
public double midPoint(double size, int number)
size
- the size of each intervalnumber
- the number of the interval.
The intervals are numbered from 0 to m_numIntervals.public final double[] getMidPoints()
public final RuleItem splitItemSet(int premiseLength, int[] itemArray)
premiseLength
- the length of the premiseitemArray
- a (randomly generated) item setpublic final RuleItem addCons(int[] itemArray)
itemArray
- the (randomly constructed) premise of the class association rulepublic final void updateCounters(ItemSet itemSet)
itemSet
- the item setpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler