00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef Apriori_Trie_HPP
00010 #define Apriori_Trie_HPP
00011
00016 #include "Trie.hpp"
00017 #include <fstream>
00018 #include <set>
00019 #include <vector>
00020 #include <cstdio>
00021 using namespace std;
00022
00023
00031 class Apriori_Trie
00032 {
00033 public:
00034
00035 Apriori_Trie();
00036
00038 void candidate_generation( const itemtype& frequent_size );
00039
00041 void find_candidate( const vector<itemtype>& basket, const itemtype candidate_size, const unsigned long counter=1 );
00042
00044 void delete_infrequent( const unsigned long min_occurrence, const itemtype candidate_size );
00045
00047 void association( ofstream& outcomefile, const double min_conf ) const;
00048
00050 void basket_recode( vector<itemtype>& basket ) const;
00051
00053 unsigned long longest_path() const;
00054
00056 void write_content_to_file( ofstream& outcomefile ) const;
00057
00059 void show_content_preorder( ) const;
00060
00061 ~Apriori_Trie();
00062
00063 protected:
00064
00066 bool is_all_subset_frequent( const set<itemtype>& maybe_candidate ) const;
00067
00069 void candidate_generation_two();
00070
00072 void candidate_generation_assist( Trie* Trie, const itemtype distance_from_generator,
00073 set<itemtype>& maybe_candidate );
00074
00076 void find_candidate_one( const vector<itemtype>& basket );
00077
00079 void find_candidate_two( const vector<itemtype>& basket, const unsigned long counter=1 );
00080
00082 void delete_infrequent_one( const unsigned long min_occurrence );
00083
00085 void delete_infrequent_two( const unsigned long min_occurrence );
00086
00087
00088 void assoc_rule_find( ofstream& outcomefile, const double min_conf, set<itemtype>& condition_part,
00089 set<itemtype>& consequence_part, const unsigned long union_support) const;
00090
00091 void assoc_rule_assist( ofstream& outcomefile, const double min_conf, Trie* Trie,
00092 set<itemtype>& consequence_part) const;
00093
00095 void write_content_to_file_assist( ofstream& outcomefile, Trie* actual_state, const itemtype distance_from_frequent,
00096 set<itemtype>& frequent_itemset) const;
00097 private:
00098
00099
00100 public:
00101
00102
00103 protected:
00105 Trie* main_trie;
00106
00111 vector< vector<unsigned long> > temp_counter_array;
00112 vector< unsigned long > temp_counter_vector;
00117 vector<itemtype> orderarray;
00118
00120 vector<itemtype> inv_orderarray;
00121
00122 };
00123
00124 #endif