Class AbstractFinder

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

public abstract class AbstractFinder extends Object implements AutoCloseable
Abstract base class for growing and pruning procedures for all types of rules (classification, regression, survival).
  • Field Details

    • params

      protected final InductionParameters params
      Rule induction parameters.
    • threadCount

      protected int threadCount
      Number of threads to be used by the induction algorithm.
    • pool

      protected ExecutorService pool
      Thread pool to be used by the algorithm.
    • modifier

      protected IQualityModifier modifier
    • attributeValuesOrder

      protected Map<IAttribute,List<Integer>> attributeValuesOrder
  • Constructor Details

    • AbstractFinder

      public AbstractFinder(InductionParameters params)
      Initializes induction parameters and thread pool.
      Parameters:
      params - Induction parameters.
  • Method Details

    • addObserver

      public void addObserver(IFinderObserver o)
    • clearObservers

      public void clearObservers()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • preprocess

      public void preprocess(IExampleSet trainSet)
      Can be implemented by subclasses to perform some initial processing prior growing.
      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.
      Parameters:
      rule - Rule to be grown.
      dataset - Training set.
      uncovered - Collection of examples yet uncovered by the model (positive examples in the classification problems).
      Returns:
      Number of conditions added.
    • prune

      public void prune(Rule rule, IExampleSet trainSet, Set<Integer> uncovered)
      Removes irrelevant conditions from rule using hill-climbing strategy.
      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)
      Postprocesses a rule.
      Parameters:
      rule - Rule to be postprocessed.
      dataset - Training set.
    • induceCondition

      protected abstract ElementaryCondition induceCondition(Rule rule, IExampleSet trainSet, Set<Integer> uncoveredByRuleset, Set<Integer> coveredByRule, Set<IAttribute> allowedAttributes, Pair<String,Object>... extraParams)
      Abstract method representing all procedures which induce an elementary condition.
      Parameters:
      rule - Current rule.
      trainSet - Training set.
      uncoveredByRuleset - Set of 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.
    • names2attributes

      protected Set<IAttribute> names2attributes(Set<String> names, IExampleSet dataset)
      Maps a set of attribute names to a set of attributes.
      Parameters:
      names - Set of attribute names.
      dataset - Training set.
      Returns:
      Set of attributes.
    • notifyGrowingStarted

      protected void notifyGrowingStarted(Rule r)
    • notifyGrowingFinished

      protected void notifyGrowingFinished(Rule r)
    • notifyConditionAdded

      protected void notifyConditionAdded(ConditionBase cnd)
    • notifyConditionRemoved

      protected void notifyConditionRemoved(ConditionBase cnd)
    • notifyRuleReady

      protected void notifyRuleReady(Rule r)