⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classmsapriori.html

📁 Aprior的C++实现算法
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>APRIORI algorithm: MSApriori class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.5 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div><h1>MSApriori Class Reference</h1>This class implements the MSAPRIORI algirithm.  <a href="#_details">More...</a><p><code>#include &lt;<a class="el" href="MSApriori_8hpp-source.html">MSApriori.hpp</a>&gt;</code><p>Collaboration diagram for MSApriori:<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classMSApriori-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#a0">MSApriori</a> (ifstream &amp;basket_file, const char *output_file_name, const bool <a class="el" href="classMSApriori.html#r3">store_input</a>)</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#a1">MSAPRIORI_alg</a> (ifstream &amp;mis_file, const double min_conf, const bool quiet, const unsigned long size_threshold)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This procedure implements the MSAPRIORI algorithm.  <a href="#a1"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#a2">~MSApriori</a> ()</td></tr><tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#d0">support</a> (const <a class="el" href="common_8hpp.html#a0">itemtype</a> &amp;candidate_size)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determines the support of the candidates of the given size.  <a href="#d0"></a><br><br></td></tr><tr><td colspan=2><br><h2>Private Attributes</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="classMSApriori__Trie.html">MSApriori_Trie</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#r0">msapriori_trie</a></td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A trie that stores the frequent itemset and candidates.  <a href="#r0"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="classInput__Output__Manager.html">Input_Output_Manager</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#r1">input_output_manager</a></td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The input_output_manager that is responsibel for the input, output and recoding operations.  <a href="#r1"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>map&lt; vector&lt; <a class="el" href="common_8hpp.html#a0">itemtype</a> &gt;, unsigned <br>long &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#r2">reduced_baskets</a></td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This will store the reduced baskets, if store_input=true;.  <a href="#r2"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classMSApriori.html#r3">store_input</a></td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">If store_input = true, then the reduced baskets will be stored in memory.  <a href="#r3"></a><br><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This class implements the MSAPRIORI algirithm. <p>MSAPRIORI is a levelwise algorithm. It scans the transaction database several times. After the first scan the frequent 1-itemsets are found, and in general after the <em>k<sup>th</sup></em> scan the frequent <em>k</em>-itemsets are extracted. The method does not determine the support of every possible itemset. In an attempt to narrow the domain to be searched, before every pass it generates <em>candidate</em> itemsets. An itemset becomes a candidate if almost every subset of it is frequent. Obviously every frequent itemset needs to be candidate too, hence only the support of candidates is calculated. Frequent <em>k</em>-itemsets generate the candidate <em>k+1</em>-itemsets after the <img class=formulaInl alt="$k^{th}$" src="form_11.png"> scan. <p>After all the candidate <em>k+1</em>-itemsets have been generated, a new scan of the transactions is effected and the precise support of the candidates is determined. The candidates with low support are thrown away. The algorithm ends when no candidates can be generated. <p>The intuition behind candidate generation is based on the following simple fact:<br> <div align="center"><em>All but one subset of a frequent itemset is frequent.</em></div><br> This is immediate, because if a transaction <em>t</em> supports an itemset <em>X</em>, then <em>t</em> supports every subset <img class=formulaInl alt="$Y\subseteq X$" src="form_12.png">. So the support of a subset <em>X</em> is greater than or equal with the support of <em>X</em>. However due to the different support thresholds a subset may not be freuent even if it has greater support. Fortunatelly this only applies to one subset (<em>X'</em>), that can be obtained from <em>X</em> if we delete the item that has the smallest support threshold. Notice, that if the support threshold of <em>X'</em> is the same as the support threshold of <em>X</em>, then this exception needs not to be considered in the candidate generation. Candidate generation of itempairs also differs from the original APRIORI method. Reader is refered to the paper for further information. <p>Using the fact indirectly, we infer, that if an itemset has a subset (not the one mentioned above) that is infrequent, then it cannot be frequent. So in the algorithm MSAPRIORI only those itemsets will be candidates whose all but one subsets are frequent. The frequent <em>k</em>-itemsets are available when we attempt to generate candidate <em>k+1</em>-itemsets. The algorithm seeks candidate <em>k+1</em>-itemsets among the sets which are unions of two frequent <em>k</em>-itemsets. After forming the union we need to verify that all of its subsets are frequent, otherwise it should not be a candidate. To this end, it is clearly enough to check if all the <em>k</em>-subsets of <em>X</em> are frequent. <p>Next the supports of the candidates are calculated. This is done by reading transactions one by one. For each transaction <em>t</em> the algorithm decides which candidates are supported by <em>t</em>. To solve this task efficiently MSAPRIORI uses a hash-tree. However in this implementation a trie (prefix-tree) is applied. Tries have many advantages over hash-trees. <ol><li>It is faster  </li><li>It needs no parameters (main drawback of a hash-tree is that its performance is very sensitive to the parameteres)  </li><li>The candidate generation is very simple.  </li></ol><p><p>Definition at line <a class="el" href="MSApriori_8hpp-source.html#l00072">72</a> of file <a class="el" href="MSApriori_8hpp-source.html">MSApriori.hpp</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2><a class="anchor" name="a0" doxytag="MSApriori::MSApriori" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> MSApriori::MSApriori </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">ifstream &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>basket_file</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const char *&nbsp;</td>          <td class="mdname" nowrap> <em>output_file_name</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const bool&nbsp;</td>          <td class="mdname" nowrap> <em>store_input</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign=top><em>basket_file</em>&nbsp;</td><td>The file that contain the transactions. </td></tr>    <tr><td valign=top><em>output_file_name</em>&nbsp;</td><td>The name of file where the results have to be written to.</td></tr>    <tr><td valign=top><em>store_input</em>&nbsp;</td><td>If store_input = true, then the reduced baskets will be stored in memory </td></tr>  </table></dl><p>Definition at line <a class="el" href="MSApriori_8cpp-source.html#l00054">54</a> of file <a class="el" href="MSApriori_8cpp-source.html">MSApriori.cpp</a>.    </td>  </tr></table><a class="anchor" name="a2" doxytag="MSApriori::~MSApriori" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> MSApriori::~<a class="el" href="classMSApriori.html">MSApriori</a> </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="MSApriori_8cpp-source.html#l00127">127</a> of file <a class="el" href="MSApriori_8cpp-source.html">MSApriori.cpp</a>.<p>References <a class="el" href="MSApriori_8hpp-source.html#l00090">msapriori_trie</a>.    </td>  </tr></table><hr><h2>Member Function Documentation</h2><a class="anchor" name="a1" doxytag="MSApriori::MSAPRIORI_alg" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> void MSApriori::MSAPRIORI_alg </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">ifstream &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>mis_file</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const double&nbsp;</td>          <td class="mdname" nowrap> <em>min_conf</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const bool&nbsp;</td>          <td class="mdname" nowrap> <em>quiet</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const unsigned long&nbsp;</td>          <td class="mdname" nowrap> <em>size_threshold</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -