Class AprioriMiner<T>

  • Type Parameters:
    T - the type of items
    All Implemented Interfaces:
    AssociationRuleMiner<T>

    public class AprioriMiner<T>
    extends AbstractAssociationRuleMiner<T>
    Implements the classical Apriori algorithm for association rule mining, cf. [R. Agrawal, R. Srikant. Fast algorithms for mining association rules in large databases. VLDB 1994.]
    Author:
    Matthias Thimm
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double minconf
      the minimum support for mined rules.
      private double minsupport
      the minimum confidence for mined rules.
    • Constructor Summary

      Constructors 
      Constructor Description
      AprioriMiner​(double minsupport, double minconf)
      Creates a new Apriori miner with the given minimum support and minimum confidence values.
    • Method Summary

      Modifier and Type Method Description
      private boolean checkSubsetCondition​(java.util.Collection<T> set, java.util.Collection<java.util.Collection<T>> sets)
      Checks whether all subsets of set obtained by removing exactly one element, are contained in the given sets.
      private java.util.Collection<java.util.Collection<T>> mineFrequentSets​(java.util.Collection<java.util.Collection<T>> database, int maxsize)
      Extracts all sets of items from database with support at least minsupport.
      java.util.Collection<AssociationRule<T>> mineRules​(java.util.Collection<java.util.Collection<T>> database, int conclusion_limit, int total_limit)
      Mines a set of association rules from the given database.
      private java.util.Collection<java.util.Collection<T>> nextLevel​(java.util.Collection<java.util.Collection<T>> lastLevel, int cardinality)
      Generates all sets of cardinality cardinality s.t.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • minsupport

        private double minsupport
        the minimum confidence for mined rules.
      • minconf

        private double minconf
        the minimum support for mined rules.
    • Constructor Detail

      • AprioriMiner

        public AprioriMiner​(double minsupport,
                            double minconf)
        Creates a new Apriori miner with the given minimum support and minimum confidence values.
        Parameters:
        minsupport - the minimum confidence for mined rules.
        minconf - the minimum support for mined rules.
    • Method Detail

      • mineRules

        public java.util.Collection<AssociationRule<T>> mineRules​(java.util.Collection<java.util.Collection<T>> database,
                                                                  int conclusion_limit,
                                                                  int total_limit)
        Description copied from interface: AssociationRuleMiner
        Mines a set of association rules from the given database. Only those rules are mined where the conclusion and in total has the maximal given number of elements, respectively.
        Parameters:
        database - some database
        conclusion_limit - the maximal size of elements in the conclusion of the mined rules.
        total_limit - the total number of elements that may appear in the mined rules.
        Returns:
        a set of association rules.
      • mineFrequentSets

        private java.util.Collection<java.util.Collection<T>> mineFrequentSets​(java.util.Collection<java.util.Collection<T>> database,
                                                                               int maxsize)
        Extracts all sets of items from database with support at least minsupport.
        Parameters:
        database - some database
        maxsize - the maximal size of mined item sets
        Returns:
        all sets of items from database with support at least minsupport.
      • nextLevel

        private java.util.Collection<java.util.Collection<T>> nextLevel​(java.util.Collection<java.util.Collection<T>> lastLevel,
                                                                        int cardinality)
        Generates all sets of cardinality cardinality s.t. all subsets of cardinality cardinality-1 are contained in the given set lastLevel.
        Parameters:
        lastLevel - a set of sets of the same cardinality cardinality
        cardinality - the cardinality of all sets in lastLevel
        Returns:
        all sets of cardinality cardinality s.t. all subsets of cardinality cardinality-1 are contained in the given set lastLevel.
      • checkSubsetCondition

        private boolean checkSubsetCondition​(java.util.Collection<T> set,
                                             java.util.Collection<java.util.Collection<T>> sets)
        Checks whether all subsets of set obtained by removing exactly one element, are contained in the given sets.
        Parameters:
        set - some set
        sets - a set of sets
        Returns:
        "true" iff all subsets of set obtained by removing exactly one element, are contained in the given sets.