|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.associations.tertius.Rule
Class representing a rule with a body and a head.
Field Summary | |
static java.util.Comparator |
confirmationComparator
Comparator used to compare two rules according to their confirmation value. |
static java.util.Comparator |
confirmationThenObservedComparator
Comparator used to compare two rules according to their confirmation and then their observed number of counter-instances. |
private Body |
m_body
The body of the rule. |
private boolean |
m_classRule
Is this rule a classification rule ? |
private double |
m_confirmation
Confirmation of this rule. |
private int |
m_counter
Counter for the counter-instances of this rule. |
private java.util.ArrayList |
m_counterInstances
Set of counter-instances of this rule. |
private Head |
m_head
The head of the rule. |
private int |
m_maxLiterals
Maximal number of literals in the rule. |
private boolean |
m_negBody
Can there be negations in the body ? |
private boolean |
m_negHead
Can there be negations in the head ? |
private int |
m_numInstances
Number of instances in the data this rule deals with. |
private double |
m_optimistic
Optimistic estimate of this rule. |
private boolean |
m_repeatPredicate
Can repeat predicates in the rule ? |
private boolean |
m_singleHead
Can there be only one literal in the head ? |
static java.util.Comparator |
observedComparator
Comparator used to compare two rules according to their observed number of counter-instances. |
static java.util.Comparator |
optimisticComparator
Comparator used to compare two rules according to their optimistic estimate. |
static java.util.Comparator |
optimisticThenObservedComparator
Comparator used to compare two rules according to their optimistic estimate and then their observed number of counter-instances. |
Constructor Summary | |
Rule(boolean repeatPredicate,
int maxLiterals,
boolean negBody,
boolean negHead,
boolean classRule,
boolean horn)
Constructor for a rule when the counter-instances are not stored, giving all the constraints applied to this rule. |
|
Rule(Instances instances,
boolean repeatPredicate,
int maxLiterals,
boolean negBody,
boolean negHead,
boolean classRule,
boolean horn)
Constructor for a rule when the counter-instances are stored, giving all the constraints applied to this rule. |
Method Summary | |
private Rule |
addTermToBody(Literal newLit)
Add a literal to the body of the rule. |
private Rule |
addTermToHead(Literal newLit)
Add a literal to the head of the rule. |
boolean |
bodyContains(Literal lit)
Test if the body of the rule contains a literal. |
void |
calculateConfirmation()
Calculate the confirmation of this rule. |
void |
calculateOptimistic()
Calculate the optimistic estimate of this rule. |
java.lang.Object |
clone()
Returns a shallow copy of this rule. |
boolean |
counterInstance(Instance instance)
Test if an instance is a counter-instance of this rule. |
boolean |
equivalentTo(Rule otherRule)
Test if this rule is equivalent to another rule. |
double |
getConfirmation()
Get the confirmation value of this rule. |
double |
getExpectedFrequency()
Get the expected frequency of counter-instances of this rule. |
double |
getExpectedNumber()
|
double |
getFPRate()
Get the rate of False Positive instances of this rule. |
double |
getObservedFrequency()
Get the observed frequency of counter-instances of this rule in the dataset. |
int |
getObservedNumber()
Get the observed number of counter-instances of this rule in the dataset. |
double |
getOptimistic()
Get the optimistic estimate of the confirmation obtained by refining this rule. |
double |
getTPRate()
Get the rate of True Positive instances of this rule. |
boolean |
hasFalseHead()
Test if the head of the rule is false. |
boolean |
hasTrueBody()
Test if the body of the rule is true. |
boolean |
headContains(Literal lit)
Test if the head of the rule contains a literal. |
boolean |
isEmpty()
Test if this rule is empty. |
int |
numLiterals()
Give the number of literals in this rule. |
boolean |
overFrequencyThreshold(double minFrequency)
Test if this rule is over the frequency threshold. |
SimpleLinkedList |
refine(java.util.ArrayList predicates)
Refine a rule by adding literal from a set of predictes. |
private SimpleLinkedList |
refine(Predicate pred,
int firstIndex,
int lastIndex,
boolean addToBody,
boolean addToHead)
Refine a rule by adding a range of literals of a predicate, either to the head or to the body of the rule. |
java.lang.String |
rocToString()
Return a String giving the TP-rate and FP-rate of this rule. |
boolean |
sameClauseAs(Rule otherRule)
Test if this rule and another rule correspond to the same clause. |
boolean |
subsumes(Rule otherRule)
Test if this rule subsumes another rule. |
java.lang.String |
toString()
Retrun a String for this rule. |
void |
upDate(Instances instances)
Update the number of counter-instances of this rule in the dataset. |
java.lang.String |
valuesToString()
Return a String giving the confirmation and optimistic estimate of this rule. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private Body m_body
private Head m_head
private boolean m_repeatPredicate
private int m_maxLiterals
private boolean m_negBody
private boolean m_negHead
private boolean m_classRule
private boolean m_singleHead
private int m_numInstances
private java.util.ArrayList m_counterInstances
private int m_counter
private double m_confirmation
private double m_optimistic
public static java.util.Comparator confirmationComparator
public static java.util.Comparator observedComparator
public static java.util.Comparator optimisticComparator
public static java.util.Comparator confirmationThenObservedComparator
public static java.util.Comparator optimisticThenObservedComparator
Constructor Detail |
public Rule(boolean repeatPredicate, int maxLiterals, boolean negBody, boolean negHead, boolean classRule, boolean horn)
repeatPredicate
- True if predicates can be repeated.maxLiterals
- Maximum number of literals.negBody
- True if negation is allowed in the body.negHead
- True if negation is allowed in the head.classRule
- True if the rule is a classification rule.horn
- True if the rule is a horn clause.public Rule(Instances instances, boolean repeatPredicate, int maxLiterals, boolean negBody, boolean negHead, boolean classRule, boolean horn)
instances
- The dataset.repeatPredicate
- True if predicates can be repeated.maxLiterals
- Maximum number of literals.negBody
- True if negation is allowed in the body.negHead
- True if negation is allowed in the head.classRule
- True if the rule is a classification rule.horn
- True if the rule is a horn clause.Method Detail |
public java.lang.Object clone()
public boolean counterInstance(Instance instance)
instance
- The instance to test.
public void upDate(Instances instances)
instances
- The dataset.public double getConfirmation()
public double getOptimistic()
public double getExpectedNumber()
public double getExpectedFrequency()
public int getObservedNumber()
public double getObservedFrequency()
public double getTPRate()
public double getFPRate()
public void calculateConfirmation()
public void calculateOptimistic()
public boolean isEmpty()
public int numLiterals()
private Rule addTermToBody(Literal newLit)
newLit
- The literal to add.
private Rule addTermToHead(Literal newLit)
newLit
- The literal to add.
private SimpleLinkedList refine(Predicate pred, int firstIndex, int lastIndex, boolean addToBody, boolean addToHead)
pred
- The predicate to consider.firstIndex
- The index of the first literal of the predicate to add.lastIndex
- The index of the last literal of the predicate to add.addToHead
- True if the literals should be added to the head.
public SimpleLinkedList refine(java.util.ArrayList predicates)
predicates
- The predicates available.
public boolean subsumes(Rule otherRule)
otherRule
- The other rule.
public boolean sameClauseAs(Rule otherRule)
otherRule
- The other rule.
public boolean equivalentTo(Rule otherRule)
otherRule
- The other rule.
public boolean bodyContains(Literal lit)
lit
- The literal to look for.
public boolean headContains(Literal lit)
lit
- The literal to look for.
public boolean overFrequencyThreshold(double minFrequency)
minFrequency
- The frequency threshold.
public boolean hasTrueBody()
public boolean hasFalseHead()
public java.lang.String valuesToString()
public java.lang.String rocToString()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |