<?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; Data Mining</title>
	<atom:link href="http://www.tylerclemons.com/tag/data-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>
		<item>
		<title>Weka, Ruby, Decision Trees</title>
		<link>http://www.tylerclemons.com/weka-ruby-decision-trees/</link>
		<comments>http://www.tylerclemons.com/weka-ruby-decision-trees/#comments</comments>
		<pubDate>Sat, 15 May 2010 20:40:26 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Weka]]></category>
		<category><![CDATA[Decision Trees]]></category>
		<category><![CDATA[rjb]]></category>

		<guid isPermaLink="false">http://www.tylerclemons.com/?p=276</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 Decision Trees.
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 Decision Trees.</p>
<p><span id="more-276"></span><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 running a Decision Tree.</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>dtree()</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 the initial tree</span><br />
obj = <span style="color: #008000;">Rjb</span>::import(<span style="color: #ffcc00;">&#8220;weka.classifiers.trees.J48&#8243;</span>)<br />
dtree = 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 />
labor_src = Rjb::import(<span style="color: #ffcc00;">&#8220;java.io.FileReader&#8221;</span>).new(<span style="color: #ffcc00;">&#8220;labor.arff&#8221;</span>)<br />
labor_data = Rjb::import(<span style="color: #ffcc00;">&#8220;weka.core.Instances&#8221;</span>).new(labor_src)</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#set the class attribute, here it&#8217;s the last value, and then build the classifier</span><br />
labor_data.setClassIndex(labor_data.numAttributes() &#8211; 1)<br />
dtree.buildClassifier(labor_data)<br />
puts dtree.toString</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#examine the particular datapoints</span><br />
points = labor_data.numInstances<br />
points.times {|instance|</p>
<p style="padding-left: 60px;">theclass = dtree.classifyInstance(labor_data.instance(instance))<br />
point = labor_data.instance(instance).toString<br />
puts <span style="color: #ff6600;">&#8220;#{point} \t #{theclass}&#8221;</span></p>
<p style="padding-left: 30px;">}</p>
<p><span style="color: #800080;">end</span></p>
<p><span style="color: #ff0000;">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span><br />
dtree()</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 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-decision-trees/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weka and Ruby</title>
		<link>http://www.tylerclemons.com/weka-and-ruby/</link>
		<comments>http://www.tylerclemons.com/weka-and-ruby/#comments</comments>
		<pubDate>Thu, 06 May 2010 17:21:15 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Weka]]></category>
		<category><![CDATA[rjb]]></category>
		<category><![CDATA[K-Means]]></category>

		<guid isPermaLink="false">http://www.tylerclemons.com/?p=256</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.  One could use JRuby, but I wanted to try this method [...]]]></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.  One could use JRuby, but I wanted to try this method to eliminate the dependency with JRuby.</p>
<p><span id="more-256"></span><strong>Setup</strong></p>
<p>The first step is to install Java.  That&#8217;s very simple, just follow <a title="Java" href="http://java.sun.com/javase/downloads/index.jsp">this link</a> to download Java.  be sure to download the JDK.</p>
<p>Getting Rjb, which stands for Ruby Java Bridge, is a ruby-gem.  You can either install the gem using the command line:</p>
<div id="codebox" style="overflow: auto; "><code><br />
gem install rjb<br />
</code></div>
<p>or, we can download the gem from <a title="Rjb" href="http://rubyforge.org/frs/?group_id=2010&amp;release_id=6285">this link.</a> The readme inside the gem is very easy to follow.<a title="Rjb" href="http://rubyforge.org/frs/?group_id=2010&amp;release_id=6285"><br />
</a></p>
<p>The last step in setup is obtaining Weka.  On the download page of Weka, choose &#8220;<strong>Other platforms (Linux, etc.)</strong>&#8220;  Inside, we find a jar file called &#8220;weka.jar&#8221;  This is what we need to continue. <strong> </strong></p>
<p><strong>Running Weka</strong></p>
<p>The following is an example of running the SimpleKmeans classifier.</p>
<div id="codebox" style="overflow: auto; "><code><br />
require <span style="color: #ffcc00;">'rjb'</span></code></p>
<p><span style="color: #ff0000;">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span><br />
<span style="color: #800080;">def </span>kmeans()</p>
<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 k-means classifier</span><br />
obj = <span style="color: #008000;">Rjb</span>::import(<span style="color: #ffcc00;">&#8220;weka.clusterers.SimpleKMeans&#8221;</span>)<br />
kmeans = 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 />
labor_src = Rjb::import(<span style="color: #ffcc00;">&#8220;java.io.FileReader&#8221;</span>).new(<span style="color: #ffcc00;">&#8220;labor.arff&#8221;</span>)<br />
labor_data = Rjb::import(<span style="color: #ffcc00;">&#8220;weka.core.Instances&#8221;</span>).new(labor_src)</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#build the cluster and output the k-means data</span><br />
kmeans.buildClusterer(labor_data)<br />
puts kmeans.toString</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">#examine the particular datapoints</span><br />
points = labor_data.numInstances<br />
points.times {|instance|</p>
<p style="padding-left: 60px;">cluster = kmeans.clusterInstance(labor_data.instance(instance))<br />
point = labor_data.instance(instance).toString<br />
puts <span style="color: #ff6600;">&#8220;#{point} \t #{cluster}&#8221;</span></p>
<p style="padding-left: 30px;">}</p>
<p><span style="color: #800080;">end</span></p>
<p><span style="color: #ff0000;">#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span><br />
kmeans()</div>
<p>This is a simple example of how to use K-means.  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 is found inside the data folder downloaded with weka.jar.</p>
<p>I will probably look at the other classifiers and post some more example.  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-and-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

