Biorithm  1.1
Public Member Functions | Protected Member Functions
AprioriWithComplement Class Reference

A class that implements the Apriori algorithm with "complements". The user passes a binary matrix to the constructor. For each row in the matrix, the constructor adds the complement of the row to the matrix. The computeItemsets() method computes itemsets in this augmented matrix with one constraint: every computed itemset will contain at least one original (non-complemented) row. Since most matrices are sparse (they contain very few ones), the complement rows contain a very large number of ones. There could be a very large number of itemsets containing only complement rows. This constraint prevents the algorithm from computing these itemsets. ! More...

#include <apriori.h>

Inheritance diagram for AprioriWithComplement:
Apriori

List of all members.

Public Member Functions

 AprioriWithComplement (vector< vector< unsigned int > > &matrix, map< unsigned int, string > &majorNames, map< unsigned int, string > &minorNames)
 Constructor that reads a binary matrix from a file.
virtual ~AprioriWithComplement ()
 Destructor.
virtual void computeItemsets (const set< unsigned int > *rowsToAvoidInSeed=NULL, const set< unsigned int > *rowsToAvoidCompletely=NULL)
virtual AprioriLatticeEdgeType computeLatticeEdgeType (const Itemset &itm1, const Itemset &itm2) const

Protected Member Functions

virtual void _computeAllRows (vector< unsigned int > &allRows) const
virtual unsigned int _computeRandomRows (const vector< unsigned int > &allRows, vector< unsigned int > &randomRows) const
virtual bool _isComplementRow (unsigned int index) const
virtual unsigned int _getOriginalRow (unsigned int index) const

Detailed Description

A class that implements the Apriori algorithm with "complements". The user passes a binary matrix to the constructor. For each row in the matrix, the constructor adds the complement of the row to the matrix. The computeItemsets() method computes itemsets in this augmented matrix with one constraint: every computed itemset will contain at least one original (non-complemented) row. Since most matrices are sparse (they contain very few ones), the complement rows contain a very large number of ones. There could be a very large number of itemsets containing only complement rows. This constraint prevents the algorithm from computing these itemsets. !


Constructor & Destructor Documentation

AprioriWithComplement::AprioriWithComplement ( vector< vector< unsigned int > > &  matrix,
map< unsigned int, string > &  majorNames,
map< unsigned int, string > &  minorNames 
)

Constructor that reads a binary matrix from a file.

Create an instance of Apriori from a file. The file must be in the form of a tab delimited matrix with the first row containing the column names. Each row must begin with the row name. The first token of the first row must exist, but can be any value.


Member Function Documentation

void AprioriWithComplement::computeItemsets ( const set< unsigned int > *  rowsToAvoidInSeed = NULL,
const set< unsigned int > *  rowsToAvoidCompletely = NULL 
) [virtual]

Compute closed itemsets in the data using the Apriori algorithm.

Parameters:
[in]rowsToAvoidInSeed,apointer to a set of rows to avoid when computing single-row itemsets. The method starts by computing itemsets with single rows. If a row is a member of this set, the method will not use that row to compute a single-row itemset. The row may be used later in computing itemsets with more than one row.
[in]rowsToAvoidCompletely,apointer to a set of rows to avoid when computing any itemset, including single-row itemsets.
Note:
Use the Apriori::getItemsets() method to retrieve the itemsets.

Reimplemented from Apriori.

AprioriLatticeEdgeType AprioriWithComplement::computeLatticeEdgeType ( const Itemset itm1,
const Itemset itm2 
) const [virtual]

Compute the type of the edge between two itemsets.

Parameters:
[in]itm1,aninstance of Itemset.
[in]itm2,aninstance of Itemset.
Returns:
LATTICE_NO_EDGE if there is no relationship between the two itemsets, LATTICE_EDGE if itm1's rows contain itm2's rows, and LATTICE_COMPLEMENT_EDGE if itm1's rows contain the complement of itm2's rows.

Reimplemented from Apriori.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Friends