java.lang.Object
adaa.analytics.rules.logic.representation.rule.Rule
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ClassificationRule, RegressionRule, SurvivalRule

public abstract class Rule extends Object implements Serializable, Cloneable
Abstract class representing all kinds of rules (classification/regression/survival).
See Also:
  • Field Details

    • stats

      protected Map<String,Object> stats
    • premise

      protected CompoundCondition premise
      Rule premise.
    • consequence

      protected ElementaryCondition consequence
      Rule consequence.
    • weighted_p

      public double weighted_p
      Number of positives covered by the rule (accounting weights).
    • weighted_n

      public double weighted_n
      Number of negatives covered by the rule (accounting weights).
    • weighted_P

      public double weighted_P
      Number of positives in the training set (accounting weights).
    • weighted_N

      public double weighted_N
      Number of negatives in the training set (accounting weights).
    • weight

      protected double weight
      Rule weight.
    • pvalue

      protected double pvalue
      Rule significance.
    • ruleOrderNum

      protected int ruleOrderNum
      Rule order number.
    • inducedConditionsCount

      protected int inducedConditionsCount
      Number of induced conditions.
    • coveredPositives

      protected transient IntegerBitSet coveredPositives
      Set of covered positives.
    • coveredNegatives

      protected transient IntegerBitSet coveredNegatives
      Set of covered negatives.
  • Constructor Details

    • Rule

      public Rule()
      Creates empty rule.
    • Rule

      public Rule(CompoundCondition premise, ElementaryCondition consequence)
      Creates a rule with a given premise and a consequence.
      Parameters:
      premise - Rule premise.
      consequence - Rule consequence.
    • Rule

      public Rule(Rule ref)
      Creates new rule on the basis of the reference one (incomplete shallow copy).
      Parameters:
      ref - Reference rule
  • Method Details

    • getPremise

      public CompoundCondition getPremise()
      Gets premise
    • setPremise

      public void setPremise(CompoundCondition v)
      Sets premise
    • getConsequence

      public ElementaryCondition getConsequence()
    • setConsequence

      public void setConsequence(ElementaryCondition v)
    • getWeighted_p

      public double getWeighted_p()
    • setWeighted_p

      public void setWeighted_p(double v)
    • getWeighted_n

      public double getWeighted_n()
    • setWeighted_n

      public void setWeighted_n(double v)
    • getWeighted_P

      public double getWeighted_P()
    • setWeighted_P

      public void setWeighted_P(double v)
    • getWeighted_N

      public double getWeighted_N()
    • setWeighted_N

      public void setWeighted_N(double v)
    • getWeight

      public double getWeight()
      Gets weight
    • setWeight

      public void setWeight(double v)
      Sets weight
    • getInducedConditionsCount

      public int getInducedConditionsCount()
    • setInducedContitionsCount

      public void setInducedContitionsCount(int v)
    • getRuleOrderNum

      public int getRuleOrderNum()
    • setRuleOrderNum

      public void setRuleOrderNum(int ruleOrderNum)
    • getPValue

      public double getPValue()
      Gets pvalue
    • setPValue

      public void setPValue(double v)
      Sets pvalue
    • getCoveredPositives

      public IntegerBitSet getCoveredPositives()
    • setCoveredPositives

      public void setCoveredPositives(IntegerBitSet v)
    • getCoveredNegatives

      public IntegerBitSet getCoveredNegatives()
    • setCoveredNegatives

      public void setCoveredNegatives(IntegerBitSet v)
    • getStat

      public Object getStat(String key)
    • putStat

      public void putStat(String key, Object val)
    • setCoveringInformation

      public void setCoveringInformation(Covering cov)
      Sets p,n,P,N on the basis of covering information.
      Parameters:
      cov - Covering information.
    • getCoveringInformation

      public Covering getCoveringInformation()
      Gets covering object containing p,n,P,N.
      Returns:
      Covering information.
    • covers

      @Deprecated public abstract Covering covers(IExampleSet set, Set<Integer> filterIds)
      Deprecated.
      Applies the rule on a part of a specified example set.
      Parameters:
      set - Example set.
      filterIds - Set of identifiers to be examined.
      Returns:
      Information about covering.
    • coversUnlabelled

      public Set<Integer> coversUnlabelled(IExampleSet set)
      Gets indices of covered examples without positive/negative distinction.
      Parameters:
      set - Example set to be examined.
      Returns:
      Set of indices of covered examples.
    • covers

      @Deprecated public abstract Covering covers(IExampleSet set)
      Deprecated.
      Applies the rule on a specified example set.
      Parameters:
      set - Example set.
      Returns:
      Information about covering.
    • updateWeightAndPValue

      public abstract void updateWeightAndPValue(IExampleSet trainSet, ContingencyTable ct, IQualityMeasure votingMeasure)
      Calculates weight and pvalue.
      Parameters:
      trainSet - Training set.
      ct - Contingency table.
      votingMeasure - Measure used as weight.
    • covers

      public void covers(IExampleSet set, ContingencyTable ct)
      Applies the rule on a specified example set.
      Parameters:
      set - Example set.
      ct - Output contingency table.
    • covers

      public void covers(IExampleSet set, ContingencyTable ct, Set<Integer> positives, Set<Integer> negatives)
      Applies the rule on a specified example set.
      Parameters:
      set - Example set.
      ct - Output contingency table.
      positives - Output collection of covered positive ids.
      negatives - Output collection of covered negative ids.
    • toString

      public String toString()
      Generates a text representation of the rule.
      Overrides:
      toString in class Object
      Returns:
      Text representation.
    • printStats

      public String printStats()
      Generates statistics in a text form.
      Returns:
      Rule statistics.
    • getTableHeader

      public String getTableHeader()
    • toTable

      public String toTable()
      Converts a rule to semicolon-separated tabular form with selected statistics.
      Returns:
      Tabular rule representation.
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • copyFrom

      public void copyFrom(Rule ref)