<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>超群.com的博客 &#187; association</title>
	<atom:link href="http://www.fuchaoqun.com/tag/association/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuchaoqun.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Sep 2011 15:08:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>利用orange进行关联规则挖掘</title>
		<link>http://www.fuchaoqun.com/2008/08/data-mining-with-python-orange-association_rule/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=data-mining-with-python-orange-association_rule</link>
		<comments>http://www.fuchaoqun.com/2008/08/data-mining-with-python-orange-association_rule/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 09:26:38 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[association]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[mining]]></category>
		<category><![CDATA[orange]]></category>
		<guid isPermaLink="false">http://chaoqun.17348.com/?p=54</guid>
		<description><![CDATA[本博客所有原创文章采用知识共享署名-非商业性使用-相同方式共享，转载请保留链接http://chaoqun.17348.com/2008/08/data-mining-with-python-orange-association_rule/ 最近，趁着项目的间隙，折腾了一阵数据挖掘，在同事的帮助下，对新浪音乐用户的听歌记录进行了一个简易挖掘，希望能根据用户以往的听歌记录，推荐出用户可能感兴趣的其他歌曲。 Orange： 一个模块化的C++数据挖掘包，提供python接口（好像也只提供了python接口）,网址是http://www.ailab.si/orange/ 关联分析： 我这里用的是类似购物篮分析，每个用户的听歌id是一个事务，不熟悉关联分析的同学可以去搜一些相关方面的资料。 数据准备： 简单清洗掉一些“脏”数据（逻辑上有问题的数据，比如某个用户在5s听了200首歌），得到类似下面的数据 15615,355029,750367,762147,803787,805014,999712,999712,999712,1013641,1024215,1028429 871029,952779,962769 1023040,1024077,1024215,1025600 757946,873801,873801,873801 862257,873479 286056,286056,286056,286056,286056,286056,286056,286056,286056,286056 873801,873801,873801,873801,873801,947750,947750 473221,473537,504206,504206,504206,504206,504206,504206 947750,1005430,1005430 974748,1024215 873479,873479,873801,873801,947750,965748,999721,1024215,1024215,1024215,1024215,1024215 873801,873801,873801 每一行是一个用户的听歌记录，没有做去重处理（orange示例中也没有，是不是可能会增加歌曲的权重？不清楚，没有去阅读orange代码），注意文件名一定要以.basket为扩展名，程序中文件地址是d:/datamining/sample.basket。 程序： # 导入orange包 import orange &#160; # 导入数据，注意不需要后缀 data = orange.ExampleTable&#40;&#34;d:/datamining/sample&#34;&#41; &#160; # 挖掘关联规则，输入最低支持度、最低置信度、最大项集数 rules = orange.AssociationRulesSparseInducer&#40;data, support = 0.5, confidence = 0.6, maxItemSets = 1000000&#41; &#160; # 打印出规则来 for r in rules: print [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>本博客所有原创文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank">知识共享署名-非商业性使用-相同方式共享</a>，转载请保留链接<a href="http://chaoqun.17348.com/2008/08/data-mining-with-python-orange-association_rule/">http://chaoqun.17348.com/2008/08/data-mining-with-python-orange-association_rule/</a></p></blockquote>
<p>最近，趁着项目的间隙，折腾了一阵数据挖掘，在同事的帮助下，对新浪音乐用户的听歌记录进行了一个简易挖掘，希望能根据用户以往的听歌记录，推荐出用户可能感兴趣的其他歌曲。</p>
<p><strong>Orange</strong>：</p>
<p>一个模块化的C++数据挖掘包，提供python接口（好像也只提供了python接口）,网址是<a href="http://www.ailab.si/orange/" target="_blank">http://www.ailab.si/orange/</a></p>
<p><strong>关联分析</strong>：</p>
<p>我这里用的是类似购物篮分析，每个用户的听歌id是一个事务，不熟悉关联分析的同学可以去搜一些相关方面的资料。</p>
<p><strong>数据准备</strong>：</p>
<p>简单清洗掉一些“脏”数据（逻辑上有问题的数据，比如某个用户在5s听了200首歌），得到类似下面的数据</p>
<blockquote><p>15615,355029,750367,762147,803787,805014,999712,999712,999712,1013641,1024215,1028429<br />
871029,952779,962769<br />
1023040,1024077,1024215,1025600<br />
757946,873801,873801,873801<br />
862257,873479<br />
286056,286056,286056,286056,286056,286056,286056,286056,286056,286056<br />
873801,873801,873801,873801,873801,947750,947750<br />
473221,473537,504206,504206,504206,504206,504206,504206<br />
947750,1005430,1005430<br />
974748,1024215<br />
873479,873479,873801,873801,947750,965748,999721,1024215,1024215,1024215,1024215,1024215<br />
873801,873801,873801</p></blockquote>
<p>每一行是一个用户的听歌记录，没有做去重处理（orange示例中也没有，是不是可能会增加歌曲的权重？不清楚，没有去阅读orange代码），注意文件名一定要以<strong>.basket</strong>为扩展名，程序中文件地址是d:/datamining/sample.basket。</p>
<p><strong>程序</strong>：</p>
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># 导入orange包</span>
<span style="color: #ff7700;font-weight:bold;">import</span> orange
&nbsp;
<span style="color: #808080; font-style: italic;"># 导入数据，注意不需要后缀</span>
data = orange.<span style="color: black;">ExampleTable</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;d:/datamining/sample&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># 挖掘关联规则，输入最低支持度、最低置信度、最大项集数</span>
rules = orange.<span style="color: black;">AssociationRulesSparseInducer</span><span style="color: black;">&#40;</span>data, support = <span style="color: #ff4500;">0.5</span>, confidence = <span style="color: #ff4500;">0.6</span>, maxItemSets = <span style="color: #ff4500;">1000000</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#  打印出规则来</span>
<span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> rules:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%5.3f   %5.3f   %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>r.<span style="color: black;">support</span>, r.<span style="color: black;">confidence</span>, r<span style="color: black;">&#41;</span></pre></div></div>
<p>是不是非常的简单？Orange实现的是<a href="http://en.wikipedia.org/wiki/Apriori_algorithm" target="_blank">Apriori算法</a>，由于Apriori算法的问题，一旦数据量非常大，你就等着你的内存消耗光吧，反正我这边要是把所有数据都导入进去的话，笔记本1.5G的的内存根本不够用，可以试试<a href="http://www.guwendong.cn/post/2008/fpgrowth_algorithm.html" target="_blank">FP-tree算法</a>，我这边参考文章<a href="http://203.72.2.115/Ejournal/3012000602.pdf" target="_blank">利用sql改良构建fp-tree之技术</a>，已经把fp-tree的前缀路径都找出来了，需要的朋友可以私下找我要，由fp前缀路径挖频繁集需要用到递归，用sql去处理就非常费劲了，所以后面的算法还需要自己去探索。</p>
<p>居于关联规则的挖掘就告一段落，因为算法的计算复杂度非常高，效果倒不是太好（因为对于音乐，用户可能听多遍，这样打分就不一样，可能用关联规则去挖电影类的数据比较好，因为电影一般最多就看一遍），现在研究的是<a href="http://en.wikipedia.org/wiki/Collaborative_filtering" target="_blank">协同过滤</a>，如果不出意外的话，一个改良版的PHP+Mysql实现<a href="http://en.wikipedia.org/wiki/Slope_One" target="_blank">slope one</a>算法过几天就要出来了，到时候我会开源出来的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2008/08/data-mining-with-python-orange-association_rule/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
