Class ClassificationFinder

java.lang.Object
adaa.analytics.rules.logic.induction.AbstractFinder
adaa.analytics.rules.logic.induction.ClassificationFinder
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
ApproximateClassificationFinder, ClassificationExpertFinder, ClassificationFinderPrecalculated, ContrastClassificationFinder

public class ClassificationFinder extends AbstractFinder
Class for growing and pruning classification rules.
  • Field Details

    • precalculatedCoverings

      protected Map<IAttribute,Map<Double,IntegerBitSet>> precalculatedCoverings
      Map of precalculated coverings (time optimization). For each attribute there is a set of distinctive values. For each value there is a bit vector of examples covered.
    • precalculatedCoveringsComplement

      protected Map<IAttribute,Map<Double,IntegerBitSet>> precalculatedCoveringsComplement
  • Constructor Details

    • ClassificationFinder

      public ClassificationFinder(InductionParameters params)
      Initializes induction parameters.
      Parameters:
      params - Induction parameters.
  • Method Details

    • preprocess

      public void preprocess(IExampleSet trainSet)
      If example set is unweighted, method precalculates conditions coverings and stores them as bit vectors in @see precalculatedCoverings field.
      Overrides:
      preprocess in class AbstractFinder
      Parameters:
      trainSet - Training set.
    • grow

      public int grow(Rule rule, IExampleSet dataset, Set<Integer> uncovered)
      Adds elementary conditions to the rule premise until termination conditions are fulfilled.
      Overrides:
      grow in class AbstractFinder
      Parameters:
      rule - Rule to be grown.
      dataset - Training set.
      uncovered - Set of positive examples yet uncovered by the model.
      Returns:
      Number of conditions added.
    • prune

      public void prune(Rule rule, IExampleSet trainSet, Set<Integer> uncovered)
      Removes irrelevant conditions from the rule using hill-climbing strategy.
      Overrides:
      prune in class AbstractFinder
      Parameters:
      rule - Rule to be pruned.
      trainSet - Training set.
      uncovered - Collection of examples yet uncovered by the model (positive examples in the classification problems).
    • postprocess

      public void postprocess(Rule rule, IExampleSet dataset)
      Description copied from class: AbstractFinder
      Postprocesses a rule.
      Overrides:
      postprocess in class AbstractFinder
      Parameters:
      rule - Rule to be postprocessed.
      dataset - Training set.
    • induceCondition

      protected ElementaryCondition induceCondition(Rule rule, IExampleSet trainSet, Set<Integer> uncoveredPositives, Set<Integer> coveredByRule, Set<IAttribute> allowedAttributes, Pair<String,Object>... extraParams)
      Induces an elementary condition.
      Specified by:
      induceCondition in class AbstractFinder
      Parameters:
      rule - Current rule.
      trainSet - Training set.
      uncoveredPositives - Set of positive examples uncovered by the model.
      coveredByRule - Set of examples covered by the rule being grown.
      allowedAttributes - Set of attributes that may be used during induction.
      extraParams - Additional parameters.
      Returns:
      Induced elementary condition.
    • tryAddCondition

      public boolean tryAddCondition(Rule currentRule, Rule bestRule, ConditionBase condition, IExampleSet trainSet, Set<Integer> covered, Set<Integer> uncovered)
      Makes an attempt to add the condition to the rule.
      Parameters:
      currentRule - Rule to be updated.
      bestRule - Best rule found up to now. Use null value if not needed.
      condition - Condition to be added.
      trainSet - Training set.
      covered - Set of examples covered by the rules.
      Returns:
      Flag indicating whether condition has been added successfully.
    • checkCandidate

      protected boolean checkCandidate(ElementaryCondition cnd, double classId, double p, double n, double new_p, double P, double uncoveredSize, int ruleOrderNum)
      Checks if candidate condition fulfills coverage requirement.
      Parameters:
      cnd - Candidate condition.
      classId - Class identifier.
      Returns: