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
Class for growing and pruning classification rules.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<IAttribute,Map<Double, IntegerBitSet>> Map of precalculated coverings (time optimization).protected Map<IAttribute,Map<Double, IntegerBitSet>> Fields inherited from class adaa.analytics.rules.logic.induction.AbstractFinder
attributeValuesOrder, modifier, params, pool, threadCount -
Constructor Summary
ConstructorsConstructorDescriptionInitializes induction parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckCandidate(ElementaryCondition cnd, double classId, double p, double n, double new_p, double P, double uncoveredSize, int ruleOrderNum) Checks if candidate condition fulfills coverage requirement.intgrow(Rule rule, IExampleSet dataset, Set<Integer> uncovered) Adds elementary conditions to the rule premise until termination conditions are fulfilled.protected ElementaryConditioninduceCondition(Rule rule, IExampleSet trainSet, Set<Integer> uncoveredPositives, Set<Integer> coveredByRule, Set<IAttribute> allowedAttributes, Pair<String, Object>... extraParams) Induces an elementary condition.voidpostprocess(Rule rule, IExampleSet dataset) Postprocesses a rule.voidpreprocess(IExampleSet trainSet) If example set is unweighted, method precalculates conditions coverings and stores them as bit vectors in @see precalculatedCoverings field.voidprune(Rule rule, IExampleSet trainSet, Set<Integer> uncovered) Removes irrelevant conditions from the rule using hill-climbing strategy.booleantryAddCondition(Rule currentRule, Rule bestRule, ConditionBase condition, IExampleSet trainSet, Set<Integer> covered, Set<Integer> uncovered) Makes an attempt to add the condition to the rule.Methods inherited from class adaa.analytics.rules.logic.induction.AbstractFinder
addObserver, clearObservers, close, names2attributes, notifyConditionAdded, notifyConditionRemoved, notifyGrowingFinished, notifyGrowingStarted, notifyRuleReady
-
Field Details
-
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
-
-
Constructor Details
-
ClassificationFinder
Initializes induction parameters.- Parameters:
params- Induction parameters.
-
-
Method Details
-
preprocess
If example set is unweighted, method precalculates conditions coverings and stores them as bit vectors in @see precalculatedCoverings field.- Overrides:
preprocessin classAbstractFinder- Parameters:
trainSet- Training set.
-
grow
Adds elementary conditions to the rule premise until termination conditions are fulfilled.- Overrides:
growin classAbstractFinder- 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
Removes irrelevant conditions from the rule using hill-climbing strategy.- Overrides:
prunein classAbstractFinder- 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
Description copied from class:AbstractFinderPostprocesses a rule.- Overrides:
postprocessin classAbstractFinder- 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:
induceConditionin classAbstractFinder- 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:
-