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

📄 mset__cand__gen_8h-source.html

📁 这是一个用于数据挖掘的常用算法的模板库(数据挖掘的C++模板库for UNIX)
💻 HTML
字号:
<!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>DMTL: mset_cand_gen.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.7 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="annotated.html"><span>Classes</span></a></li>    <li id="current"><a href="files.html"><span>Files</span></a></li>    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>  </ul></div><h1>mset_cand_gen.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span><a name="l00002"></a>00002 <span class="comment"> *  Copyright (C) 2005 M.J. Zaki &lt;zaki@cs.rpi.edu&gt; Rensselaer Polytechnic Institute</span><a name="l00003"></a>00003 <span class="comment"> *  Written by parimi@cs.rpi.edu</span><a name="l00004"></a>00004 <span class="comment"> *  Updated by chaojv@cs.rpi.edu, alhasan@cs.rpi.edu, salems@cs.rpi.edu</span><a name="l00005"></a>00005 <span class="comment"> *</span><a name="l00006"></a>00006 <span class="comment"> *  This program is free software; you can redistribute it and/or</span><a name="l00007"></a>00007 <span class="comment"> *  modify it under the terms of the GNU General Public License</span><a name="l00008"></a>00008 <span class="comment"> *  as published by the Free Software Foundation; either version 2</span><a name="l00009"></a>00009 <span class="comment"> *  of the License, or (at your option) any later version.</span><a name="l00010"></a>00010 <span class="comment"> *</span><a name="l00011"></a>00011 <span class="comment"> *  This program is distributed in the hope that it will be useful,</span><a name="l00012"></a>00012 <span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span><a name="l00013"></a>00013 <span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><a name="l00014"></a>00014 <span class="comment"> *  GNU General Public License for more details.</span><a name="l00015"></a>00015 <span class="comment"> *</span><a name="l00016"></a>00016 <span class="comment"> *  You should have received a copy of the GNU General Public License along</span><a name="l00017"></a>00017 <span class="comment"> *  with this program; if not, write to the Free Software Foundation, Inc.,</span><a name="l00018"></a>00018 <span class="comment"> *  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.</span><a name="l00019"></a>00019 <span class="comment"> */</span><a name="l00020"></a>00020 <span class="preprocessor">#ifndef _MSET_CAND_GEN_H_</span><a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _MSET_CAND_GEN_H_</span><a name="l00022"></a>00022 <span class="preprocessor"></span><a name="l00023"></a>00023 <span class="preprocessor">#include "pattern.h"</span><a name="l00024"></a>00024 <span class="preprocessor">#include "count_support.h"</span><a name="l00025"></a>00025 <span class="preprocessor">#include "mset_iso_check.h"</span><a name="l00026"></a>00026 <span class="preprocessor">#include "mset_vat.h"</span><a name="l00027"></a>00027 <span class="preprocessor">#include "typedefs.h"</span><a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> freq_pats_count;<a name="l00030"></a>00030 <span class="keyword">extern</span> <span class="keywordtype">bool</span> print;<a name="l00031"></a>00031 <a name="l00050"></a>00050 <span class="keyword">template</span>&lt;<span class="keyword">class</span> PP, <span class="keyword">class</span> MP, <span class="keyword">class</span> PAT_ST, <span class="keyword">template</span>&lt;<span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">template</span> &lt;<span class="keyword">typename</span>&gt; <span class="keyword">class</span>&gt; <span class="keyword">class </span>CC, <a name="l00051"></a>00051          template &lt;typename&gt; class ALLOC, class SM_TYPE&gt;<a name="l00052"></a>00052 void cand_gen(const <a class="code" href="classpat__fam.html">pat_fam</a>&lt;MSET_PATTERN&gt;&amp; Fk_one, <span class="keyword">const</span> <a class="code" href="classpat__fam.html">pat_fam&lt;MSET_PATTERN&gt;</a>&amp; Fk_two, <span class="keywordtype">int</span> minsup, <a name="l00053"></a>00053               <a class="code" href="classcount__support.html">count_support&lt;MSET_PROP, V_Fkk_MINE_PROP, PAT_ST, CC, ALLOC, SM_TYPE &gt;</a>&amp; cnt_sup, <a class="code" href="classpat__fam.html">pat_fam&lt;MSET_PATTERN&gt;</a>&amp; freq_pats) {<a name="l00054"></a>00054 <a name="l00055"></a>00055   <span class="keyword">typedef</span> <a class="code" href="classpat__fam.html">pat_fam&lt;MSET_PATTERN&gt;</a> PAT_FAM;<a name="l00056"></a>00056   <span class="keyword">typedef</span> <span class="keyword">typename</span> PAT_FAM::CONST_IT PF_CIT;<a name="l00057"></a>00057   <a name="l00058"></a>00058   PF_CIT it_i, it_j;<a name="l00059"></a>00059   <span class="keywordtype">int</span> num_cands = 1;<a name="l00060"></a>00060   <a name="l00061"></a>00061   <span class="keywordflow">for</span>(it_i=Fk_one.begin(); it_i!=Fk_one.end(); it_i++) {<a name="l00062"></a>00062     <a name="l00063"></a>00063     PAT_FAM pat_fam_i;  <span class="comment">// new equivalent class </span><a name="l00064"></a>00064     MSET_PATTERN* pat_i=*it_i;<a name="l00065"></a>00065     <a name="l00066"></a>00066     <span class="keywordflow">for</span>(it_j=it_i; it_j!=Fk_one.end(); it_j++) {<a name="l00067"></a>00067       <a name="l00068"></a>00068       MSET_PATTERN* pat_j=*it_j;<a name="l00069"></a>00069 <a name="l00070"></a>00070       <span class="comment">// cout &lt;&lt; "Joining = " &lt;&lt; pat_i &lt;&lt; " and " &lt;&lt; pat_j &lt;&lt; endl;</span><a name="l00071"></a>00071       <a name="l00072"></a>00072       <span class="comment">// Generate candidates from equivalent class Fk_one.</span><a name="l00073"></a>00073       MSET_PATTERN** cand_pats = join(pat_i, pat_j);<a name="l00074"></a>00074       <a name="l00075"></a>00075       <span class="comment">// Isomorphism check, for itemset every candidate patterns pass the iso-check.</span><a name="l00076"></a>00076       check_isomorphism(cand_pats[0]);<a name="l00077"></a>00077       <a name="l00078"></a>00078       <span class="comment">// Count support of candidates, checking whether new patterns in cand_pats are frequent or not.</span><a name="l00079"></a>00079       cnt_sup.count(pat_i, pat_j, cand_pats, minsup, num_cands);<a name="l00080"></a>00080       <span class="comment">// cout &lt;&lt; "Cand pattern = " &lt;&lt; cand_pats[0] &lt;&lt; endl;</span><a name="l00081"></a>00081       <a name="l00082"></a>00082       <span class="comment">// Get rid of infrequent candidate. This is itemset</span><a name="l00083"></a>00083       <span class="comment">// so, we have only one candidate pattern.</span><a name="l00084"></a>00084       <span class="keywordflow">if</span>(!cand_pats[0]-&gt;is_freq(minsup)) {<a name="l00085"></a>00085         <span class="keyword">delete</span> cand_pats[0];<a name="l00086"></a>00086       } <span class="keywordflow">else</span> {<a name="l00087"></a>00087         <span class="comment">// pushing new and frequent candidates in new equivalent class pat_fam_i</span><a name="l00088"></a>00088         pat_fam_i.push_back(cand_pats[0]);<a name="l00089"></a>00089         <span class="comment">// pushing new and frequent candidates in freq_pats for output</span><a name="l00090"></a>00090         <span class="comment">//freq_pats.push_back(cand_pats[0]);</span><a name="l00091"></a>00091         <span class="comment">// number of frequent patterns increase by 1</span><a name="l00092"></a>00092         freq_pats_count++;<a name="l00093"></a>00093         <span class="keywordflow">if</span>(print)<a name="l00094"></a>00094           cout &lt;&lt; cand_pats[0];<a name="l00095"></a>00095       }<a name="l00096"></a>00096       <span class="comment">// delete the array of pointers holding the cand_pats </span><a name="l00097"></a>00097       <span class="keyword">delete</span>[] cand_pats;<a name="l00098"></a>00098     }<a name="l00099"></a>00099     <a name="l00100"></a>00100     cnt_sup.delete_vat(*it_i);<a name="l00101"></a>00101     <a name="l00102"></a>00102     <span class="comment">// Recursively mine the new pattern family. Depth first pattern generation</span><a name="l00103"></a>00103     <span class="keywordflow">if</span>(!pat_fam_i.empty()) {<a name="l00104"></a>00104       cand_gen(pat_fam_i, pat_fam_i, minsup, cnt_sup, freq_pats);<a name="l00105"></a>00105     <a name="l00106"></a>00106       <span class="comment">// Deleting the pat_fam_i after the recursion calls processed all its</span><a name="l00107"></a>00107       <span class="comment">// descendent patterns.</span><a name="l00108"></a>00108       pat_fam_i.clear();<a name="l00109"></a>00109     }<a name="l00110"></a>00110     <a name="l00111"></a>00111   } <span class="comment">//end for i</span><a name="l00112"></a>00112   <a name="l00113"></a>00113 } <span class="comment">//end cand_gen()</span><a name="l00114"></a>00114 <a name="l00131"></a>00131 <span class="keyword">template</span>&lt;<span class="keyword">class</span> PP, <span class="keyword">class</span> MP, <span class="keyword">class</span> PAT_ST, <span class="keyword">template</span>&lt;<span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">template</span> &lt;<span class="keyword">typename</span>&gt; <span class="keyword">class</span>&gt; <span class="keyword">class </span>CC, <a name="l00132"></a>00132          template &lt;typename&gt; class ALLOC &gt;<a name="l00133"></a>00133 MSET_PATTERN** join(<span class="keyword">const</span> MSET_PATTERN* pat_i, MSET_PATTERN* pat_j) {<a name="l00134"></a>00134   <a name="l00135"></a>00135   MSET_PATTERN** cand_pats=<span class="keyword">new</span> MSET_PATTERN*[1];  <span class="comment">// an array of one element that holds pointer to a pattern</span><a name="l00136"></a>00136                                         <span class="comment">// this allocation of memory is released in cand_gen() routine</span><a name="l00137"></a>00137                                         <span class="comment">// after we either delete the candidate, if it is infrequent</span><a name="l00138"></a>00138                                         <span class="comment">// or store it in freq_pats data structure if it is frequent </span><a name="l00139"></a>00139   cand_pats[0] = pat_i-&gt;clone();   <a name="l00140"></a>00140   <span class="keyword">const</span> <span class="keyword">typename</span> MSET_PATTERN::VERTEX_T&amp; rmv = pat_j-&gt;rmost_vertex();<a name="l00141"></a>00141   cand_pats[0]-&gt;add_vertex(rmv);<a name="l00142"></a>00142   <a name="l00143"></a>00143   <span class="keywordflow">return</span> cand_pats;<a name="l00144"></a>00144 }<a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Jul 26 14:01:08 2006 for DMTL by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address></body></html>

⌨️ 快捷键说明

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