Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

LeafRepresentationSelector.hpp

Go to the documentation of this file.
00001 #ifndef LeafRepresentationSelector_HPP
00002 #define LeafRepresentationSelector_HPP
00003 
00004 #include "io/input/transaction_reader/SortedTransactionReader.hpp"
00005 #include "io/codec/coder/Coder.hpp"
00006 #include "io/db_cache/BuildTreeDBCache.hpp"
00007 #include "util/Frequent2Filter.cpp"
00008 
00009 #include "common/allocators.hpp"
00010 
00011 
00012 #include "apriori/bodon/trie/trie_manipulators/FrequentItemInserter.hpp"
00013 #include "apriori/bodon/trie/trie_manipulators/FrequentPairInserter.hpp"
00014 #include "apriori/bodon/trie/trie_manipulators/FrequentPairInserterNoprune.hpp"
00015 
00016 #include "apriori/bodon/trie/trie_manipulators/support_counter/SupportCounterMerge.hpp"
00017 #include "apriori/OneByOneSupportCounter.hpp"
00018 
00019 #include "apriori/bodon/trie/trie_manipulators/CandidateGeneratorPrune.hpp"
00020 #include "apriori/bodon/inhomogeneous_trie/trie_manipulators/CandidateGeneratorPrune.hpp"
00021 
00022 #include "apriori/bodon/trie/trie_manipulators/SimplePruner.hpp"
00023 #include "apriori/bodon/inhomogeneous_trie/trie_manipulators/SimplePruner.hpp"
00024 
00025 #include "apriori/bodon/trie/trie_manipulators/IntersectProPruner.hpp"
00026 #include "apriori/bodon/inhomogeneous_trie/trie_manipulators/IntersectProPruner.hpp"
00027 
00028 #include "apriori/bodon/trie/trie_manipulators/CandGenInfreqRemoveNopruneMerge.hpp"
00029 #include "apriori/bodon/inhomogeneous_trie/trie_manipulators/CandGenInfreqRemoveNopruneMerge.hpp"
00030 
00031 #include "apriori/bodon/trie/trie_manipulators/InfreqRemover.hpp"
00032 #include "apriori/bodon/inhomogeneous_trie/trie_manipulators/InfreqRemover.hpp"
00033 
00034 #include "apriori/Apriori.hpp"
00035 
00036 
00037 
00038 template <class TRIE, class LEAF_WC, class LEAF_ALLOCATOR, class T_R, class DF_D> 
00039 class LeafRepresentationSelector
00040 {
00041    public:
00042       LeafRepresentationSelector( 
00043          counter_t min_supp, char* input_file,
00044          counter_t nr_of_transactions, 
00045          std::vector< std::pair<counter_t, item_t> >& freq_items_with_counters, 
00046          T_R& tr_reader, DF_D& df_decoder);
00047 };
00048 /*template <class TRIE, class LEAF_WC, class T_R, class DF_D> 
00049 class LeafRepresentationSelectorOld
00050 {
00051    public:
00052       LeafRepresentationSelectorOld( 
00053          counter_t min_supp, char* input_file,
00054          counter_t nr_of_transactions, 
00055          std::vector< std::pair<counter_t, item_t> >& freq_items_with_counters, 
00056          T_R& tr_reader, DF_D& df_decoder);
00057 };*/
00058 
00059 template <class TRIE, class LEAF_WC, class LEAF_ALLOCATOR, class T_R, class DF_D>
00060 LeafRepresentationSelector<TRIE, LEAF_WC, LEAF_ALLOCATOR, T_R, DF_D>::
00061 LeafRepresentationSelector( 
00062    counter_t min_supp, char* input_file,
00063    counter_t nr_of_transactions, 
00064    std::vector< std::pair<counter_t, item_t> >& freq_items_with_counters, 
00065    T_R& tr_reader, DF_D& df_decoder)
00066 {
00067    typedef typename bracz::BuildTreeDBCache< SortedTransactionReader<Coder<T_R, DF_D> >,  
00068       std::vector<item_t>, bracz::EndPatriciaBuildTree<true> > S_C;
00069 //   typedef SortedTransactionReader<Coder<T_R, DF_D> >  S_C;
00070 
00071    typename S_C::params_t par_c;
00072    par_c.file_name = input_file;
00073    par_c.mode=FileReprBase::READ;
00074    par_c.largest_item = tr_reader.getLargestItem();
00075    par_c.decoder = &df_decoder;
00076    par_c.freq_items_with_counters = &freq_items_with_counters;
00077    par_c.codemode = ASC;
00078    log_status(0,"Doing sorted codec.");
00079    S_C sorted_coder(&par_c);
00080 
00081    std::vector< std::pair<counter_t, std::pair<item_t, item_t> > >
00082       freq_pairs_with_counters;
00083    Frequent2Filter<S_C> fr_2_filter(
00084       &sorted_coder );
00085    log_status(0,"Finding frequent pairs.")
00086       fr_2_filter.findFrequentPairs(freq_pairs_with_counters, min_supp);
00087 
00088    TRIE main_trie;
00089    LEAF_ALLOCATOR s_alloc;
00090    typedef Bodon::FrequentItemInserter<DF_D, TRIE, true> FII;
00091    FII fii(main_trie, df_decoder);
00092    typedef Bodon::SupportCounterMerge<TRIE> SUPP_C_BASE;
00093    typedef OneByOneSupportCounter<TRIE, S_C, SUPP_C_BASE> SUPP_C;
00094 //   typedef Bodon::dynamic_trie::SupportCounter<TRIE, INHOMOGENEOUS_TRIE> SC;
00095 
00096    log_info(0,"Complete pruning is disabled.");
00097    typedef Bodon::FrequentPairInserterNoprune<DF_D, TRIE, LEAF_WC, LEAF_ALLOCATOR, true> FPI;
00098    typedef Bodon::inhomogeneous_trie::CandGenInfreqRemoveNopruneMerge<DF_D, TRIE, LEAF_WC, LEAF_ALLOCATOR, true > CGIR;
00099    CGIR infrequent_remover(main_trie, df_decoder, s_alloc);
00100    typedef Apriori<S_C, DF_D, TRIE, LEAF_ALLOCATOR, FII, FPI, CGIR, CGIR, SUPP_C> A;
00101    A apriori(main_trie, s_alloc, infrequent_remover, sorted_coder, df_decoder, fii);
00102    log_status(0,"Finding frequent itemsets.")
00103       apriori.findFrequentItemsets( 
00104          nr_of_transactions, *par_c.freq_counters,
00105          freq_pairs_with_counters, min_supp );
00106 }
00107 
00108 /*
00109 template <class TRIE, class LEAF_WC, class T_R, class DF_D>
00110 LeafRepresentationSelectorOld<TRIE, LEAF_WC, T_R, DF_D>::LeafRepresentationSelectorOld( 
00111    counter_t min_supp, char* input_file,
00112    counter_t nr_of_transactions, 
00113    std::vector< std::pair<counter_t, item_t> >& freq_items_with_counters, 
00114    T_R& tr_reader, DF_D& df_decoder)
00115 {
00116    typedef typename bracz::BuildTreeDBCache< SortedTransactionReader<Coder<T_R, DF_D> >,  
00117       std::vector<item_t>, bracz::EndPatriciaBuildTree<true> > S_C;
00118 //   typedef SortedTransactionReader<Coder<T_R, DF_D> >  S_C;
00119 
00120    typename S_C::params_t par_c;
00121    par_c.file_name = input_file;
00122    par_c.mode=FileReprBase::READ;
00123    par_c.largest_item = tr_reader.getLargestItem();
00124    par_c.decoder = &df_decoder;
00125    par_c.freq_items_with_counters = &freq_items_with_counters;
00126    par_c.codemode = ASC;
00127    log_status(0,"Doing sorted codec.");
00128    S_C sorted_coder(&par_c);
00129 
00130    std::vector< std::pair<counter_t, std::pair<item_t, item_t> > >
00131       freq_pairs_with_counters;
00132    Frequent2Filter<S_C> fr_2_filter(
00133       &sorted_coder );
00134    log_status(0,"Finding frequent pairs.")
00135       fr_2_filter.findFrequentPairs(freq_pairs_with_counters, min_supp);
00136 
00137    typedef bracz::NewWrapperAlloc<LEAF_WC> LEAF_ALLOCATOR;
00138    typedef Bodon::FrequentItemInserter<DF_D, TRIE, true> FII;
00139    typedef Bodon::SupportCounterMerge<TRIE> SC;
00140    log_info(0,"Complete pruning is disabled.");
00141    typedef Bodon::FrequentPairInserterNoprune<DF_D, TRIE, TRIE, LEAF_ALLOCATOR, true> FPI;
00142    typedef Bodon::trie::CandGenInfreqRemoveNopruneMerge<DF_D, TRIE, true> CGIR;
00143    CGIR infrequent_remover(main_trie, df_decoder, s_alloc);
00144    typedef Apriori<S_C, DF_D, TRIE, LEAF_ALLOCATOR, FII, FPI, CGIR, CGIR, SUPP_C> A;
00145    A apriori(main_trie, s_alloc, infrequent_remover, sorted_coder, df_decoder, fii);
00146    log_status(0,"Finding frequent itemsets.")
00147       apriori.findFrequentItemsets( 
00148          nr_of_transactions, *par_c.freq_counters,
00149          freq_pairs_with_counters, min_supp );
00150 }
00151 */
00152 #endif

Generated on Sun Sep 17 17:50:39 2006 for FIM environment by  doxygen 1.4.4