类 Rule

java.lang.Object
weka.associations.tertius.Rule
所有已实现的接口:
Serializable, Cloneable, RevisionHandler

public class Rule extends Object implements Serializable, Cloneable, RevisionHandler
Class representing a rule with a body and a head.
版本:
$Revision: 1.7 $
作者:
Amelie Deltour
另请参阅:
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static Comparator
    Comparator used to compare two rules according to their confirmation value.
    static Comparator
    Comparator used to compare two rules according to their confirmation and then their observed number of counter-instances.
    static Comparator
    Comparator used to compare two rules according to their observed number of counter-instances.
    static Comparator
    Comparator used to compare two rules according to their optimistic estimate.
    static Comparator
    Comparator used to compare two rules according to their optimistic estimate and then their observed number of counter-instances.
  • 构造器概要

    构造器
    构造器
    说明
    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.
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    Test if the body of the rule contains a literal.
    void
    Calculate the confirmation of this rule.
    void
    Calculate the optimistic estimate of this rule.
    Returns a shallow copy of this rule.
    boolean
    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
    Get the confirmation value of this rule.
    double
    Get the expected frequency of counter-instances of this rule.
    double
     
    double
    Get the rate of False Positive instances of this rule.
    double
    Get the observed frequency of counter-instances of this rule in the dataset.
    int
    Get the observed number of counter-instances of this rule in the dataset.
    double
    Get the optimistic estimate of the confirmation obtained by refining this rule.
    Returns the revision string.
    double
    Get the rate of True Positive instances of this rule.
    boolean
    Test if the head of the rule is false.
    boolean
    Test if the body of the rule is true.
    boolean
    Test if the head of the rule contains a literal.
    boolean
    Test if this rule is empty.
    int
    Give the number of literals in this rule.
    boolean
    overFrequencyThreshold(double minFrequency)
    Test if this rule is over the frequency threshold.
    refine(ArrayList predicates)
    Refine a rule by adding literal from a set of predictes.
    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.
    Retrun a String for this rule.
    void
    upDate(Instances instances)
    Update the number of counter-instances of this rule in the dataset.
    Return a String giving the confirmation and optimistic estimate of this rule.

    从类继承的方法 java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 字段详细资料

    • confirmationComparator

      public static Comparator confirmationComparator
      Comparator used to compare two rules according to their confirmation value.
    • observedComparator

      public static Comparator observedComparator
      Comparator used to compare two rules according to their observed number of counter-instances.
    • optimisticComparator

      public static Comparator optimisticComparator
      Comparator used to compare two rules according to their optimistic estimate.
    • confirmationThenObservedComparator

      public static Comparator confirmationThenObservedComparator
      Comparator used to compare two rules according to their confirmation and then their observed number of counter-instances.
    • optimisticThenObservedComparator

      public static Comparator optimisticThenObservedComparator
      Comparator used to compare two rules according to their optimistic estimate and then their observed number of counter-instances.
  • 构造器详细资料

    • Rule

      public 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.
      参数:
      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.
    • Rule

      public 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. The counter-instances are initialized to all the instances in the dataset.
      参数:
      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.
  • 方法详细资料

    • clone

      public Object clone()
      Returns a shallow copy of this rule. The structured is copied but the literals themselves are not copied.
      返回:
      A copy of this Rule.
    • counterInstance

      public boolean counterInstance(Instance instance)
      Test if an instance is a counter-instance of this rule.
      参数:
      instance - The instance to test.
      返回:
      True if the instance is a counter-instance.
    • upDate

      public void upDate(Instances instances)
      Update the number of counter-instances of this rule in the dataset. This method should be used is the rule does not store its counter-instances.
      参数:
      instances - The dataset.
    • getConfirmation

      public double getConfirmation()
      Get the confirmation value of this rule.
      返回:
      The confirmation.
    • getOptimistic

      public double getOptimistic()
      Get the optimistic estimate of the confirmation obtained by refining this rule.
      返回:
      The optimistic estimate.
    • getExpectedNumber

      public double getExpectedNumber()
    • getExpectedFrequency

      public double getExpectedFrequency()
      Get the expected frequency of counter-instances of this rule.
      返回:
      The expected frequency of counter-instances.
    • getObservedNumber

      public int getObservedNumber()
      Get the observed number of counter-instances of this rule in the dataset.
      返回:
      The observed number of counter-instances.
    • getObservedFrequency

      public double getObservedFrequency()
      Get the observed frequency of counter-instances of this rule in the dataset.
      返回:
      The expected frequency of counter-instances.
    • getTPRate

      public double getTPRate()
      Get the rate of True Positive instances of this rule.
      返回:
      The TP-rate.
    • getFPRate

      public double getFPRate()
      Get the rate of False Positive instances of this rule.
      返回:
      The FP-rate.
    • calculateConfirmation

      public void calculateConfirmation()
      Calculate the confirmation of this rule.
    • calculateOptimistic

      public void calculateOptimistic()
      Calculate the optimistic estimate of this rule.
    • isEmpty

      public boolean isEmpty()
      Test if this rule is empty.
      返回:
      True if it is the empty rule.
    • numLiterals

      public int numLiterals()
      Give the number of literals in this rule.
      返回:
      The number of literals.
    • refine

      public SimpleLinkedList refine(ArrayList predicates)
      Refine a rule by adding literal from a set of predictes.
      参数:
      predicates - The predicates available.
      返回:
      The list of the children obtained by refining the rule.
    • subsumes

      public boolean subsumes(Rule otherRule)
      Test if this rule subsumes another rule.
      参数:
      otherRule - The other rule.
      返回:
      True if the other rule is subsumed.
    • sameClauseAs

      public boolean sameClauseAs(Rule otherRule)
      Test if this rule and another rule correspond to the same clause.
      参数:
      otherRule - The other rule.
      返回:
      True if both rules correspond to the same clause.
    • equivalentTo

      public boolean equivalentTo(Rule otherRule)
      Test if this rule is equivalent to another rule.
      参数:
      otherRule - The other rule.
      返回:
      True if both rules are equivalent.
    • bodyContains

      public boolean bodyContains(Literal lit)
      Test if the body of the rule contains a literal.
      参数:
      lit - The literal to look for.
      返回:
      True if the literal is contained in the body of the rule.
    • headContains

      public boolean headContains(Literal lit)
      Test if the head of the rule contains a literal.
      参数:
      lit - The literal to look for.
      返回:
      True if the literal is contained in the head of the rule.
    • overFrequencyThreshold

      public boolean overFrequencyThreshold(double minFrequency)
      Test if this rule is over the frequency threshold.
      参数:
      minFrequency - The frequency threshold.
      返回:
      True if the rule is over the threshold.
    • hasTrueBody

      public boolean hasTrueBody()
      Test if the body of the rule is true.
      返回:
      True if the body is always satisfied.
    • hasFalseHead

      public boolean hasFalseHead()
      Test if the head of the rule is false.
      返回:
      True if the body is never satisfied.
    • valuesToString

      public String valuesToString()
      Return a String giving the confirmation and optimistic estimate of this rule.
      返回:
      A String with the values of the rule.
    • rocToString

      public String rocToString()
      Return a String giving the TP-rate and FP-rate of this rule.
      返回:
      A String with the values of the rule.
    • toString

      public String toString()
      Retrun a String for this rule.
      覆盖:
      toString 在类中 Object
      返回:
      The String describing this rule.
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      返回:
      the revision