<?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>Tyler Clemons &#187; Association Mining</title>
	<atom:link href="http://www.tylerclemons.com/tag/association-mining/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tylerclemons.com</link>
	<description>tylerclemons.com</description>
	<lastBuildDate>Thu, 27 Oct 2011 17:06:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Weka, Ruby, Association Mining</title>
		<link>http://www.tylerclemons.com/weka-ruby-association-mining/</link>
		<comments>http://www.tylerclemons.com/weka-ruby-association-mining/#comments</comments>
		<pubDate>Sat, 15 May 2010 21:09:17 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Weka]]></category>
		<category><![CDATA[Association Mining]]></category>
		<category><![CDATA[rjb]]></category>

		<guid isPermaLink="false">http://www.tylerclemons.com/?p=282</guid>
		<description><![CDATA[Weka is a collection of machine learning tools used for data mining.  Weka is written in Java however it is possible to use Weka&#8217;s libraries inside Ruby.  To do this, we must install the Java, Rjb, and of course obtain the Weka source code.  In this example, I look at Associating Mining.

Refer to my previous [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Weka" href="http://www.cs.waikato.ac.nz/ml/weka/" target="_blank">Weka</a> is a collection of machine learning tools used for data mining.  Weka is written in Java however it is possible to use Weka&#8217;s libraries inside Ruby.  To do this, we must install the Java, Rjb, and of course obtain the Weka source code.  In this example, I look at Associating Mining.</p>
<p><span id="more-282"></span></p>
<p><img title="More..." src="http://tylershome.nfshost.com/home/public/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /><a title="Kmeans and setup" href="http://www.tylerclemons.com/weka-and-ruby/">Refer to my previous example for setup instructions.</a></p>
<p><img title="More..." src="http://tylershome.nfshost.com/home/public/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /><strong>Running Weka</strong></p>
<p>The following is an example of a frequent itemset finder.</p>
<div id="codebox" style="overflow: auto; "><code><br />
require <span style="color: #ffcc00;">'rjb'</span></code></p>
<div style="overflow: auto; "><code><span style="color: #ffcc00;"> </span></code><span style="color: #ff0000;">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span><br />
<span style="color: #800080;">def </span>asscm()</div>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#Load Java Jar</span><br />
dir =<span style="color: #ffcc00;"> &#8220;./weka.jar&#8221;</span><br />
<span style="color: #ff0000;">#Have Rjb load the jar file, and pass Java command line arguments</span><br />
<span style="color: #008000;">Rjb</span>::load(dir, jvmargs=[<span style="color: #ffcc00;">"-Xmx1000M"</span>])</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#make initial association Miner</span><br />
obj = <span style="color: #008000;">Rjb</span>::import(<span style="color: #ffcc00;">&#8220;weka.associations.Apriori&#8221;</span>)<br />
assc= obj.new</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#load the data</span> <span style="color: #ff0000;">using Ja<span style="color: #ff0000;">va</span></span><span style="color: #ff0000;"> and Weka</span><br />
weather_src = Rjb::import(<span style="color: #ffcc00;">&#8220;java.io.FileReader&#8221;</span>).new(<span style="color: #ffcc00;">&#8220;weather.nominal.arff&#8221;</span>)<br />
weather_data = Rjb::import(<span style="color: #ffcc00;">&#8220;weka.core.Instances&#8221;</span>).new(weather_src)</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#Find the frequent itemsets</span><br />
assc.setCar(true) <span style="color: #ff0000;">#mines for class association</span><br />
assc.setLowerBoundMinSupport(0.25) <span style="color: #ff0000;">#set minimum support</span><br />
assc.buildAssociations(weather_data)<br />
puts assc.toString</p>
<p><span style="color: #800080;">end</span></p>
<p><span style="color: #ff0000;">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span><br />
asscm()</div>
<p>We first tell Rjb to load the specified classpath, for us it&#8217;s our Jar file.  I passed command line arguments that specify the amount of RAM to use.</p>
<p>Rjb::import loads specific classes.  These are relative to our classpath.</p>
<p>I call the constructor for the new classes by using the .new method from Ruby.  Afterward, I can use the new object like any other Ruby object.  The method names are as they are found in their Java source files.  For an explanation of data type conversions, <a title="Rjb explanation" href="http://rjb.rubyforge.org/">click here.</a></p>
<p>The dataset I used is different from the previous because we can&#8217;t use numerical values.  The dataset is found inside the data folder downloaded with weka.jar.</p>
<p>As I said before, this can be done in JRuby.  A great example can be found at this <a title="JRuby Example" href="http://rubyforscientificresearch.blogspot.com/2009/08/accessing-weka-from-jruby.html" target="_blank">great blog post</a>, which inspired my post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tylerclemons.com/weka-ruby-association-mining/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

