ai4r 1.2 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +12 -25
- data/examples/decision_trees/id3_example.rb +6 -9
- data/examples/decision_trees/results.txt +2 -0
- data/examples/genetic_algorithm/genetic_algorithm_example.rb +11 -13
- data/examples/neural_network/xor_example.rb +25 -0
- data/lib/ai4r.rb +10 -0
- data/lib/ai4r/classifiers/classifier.rb +46 -0
- data/lib/ai4r/classifiers/id3.rb +27 -58
- data/lib/ai4r/classifiers/one_r.rb +19 -58
- data/lib/ai4r/classifiers/prism.rb +21 -57
- data/lib/ai4r/classifiers/zero_r.rb +16 -48
- data/lib/ai4r/clusterers/bisecting_k_means.rb +115 -0
- data/lib/ai4r/clusterers/clusterer.rb +55 -0
- data/lib/ai4r/clusterers/k_means.rb +164 -0
- data/lib/ai4r/data/data_set.rb +250 -0
- data/lib/ai4r/genetic_algorithm/genetic_algorithm.rb +19 -19
- data/lib/ai4r/neural_network/backpropagation.rb +23 -24
- data/site/build/site/en/broken-links.xml +2 -0
- data/site/build/site/en/downloads.html +200 -0
- data/site/build/site/en/downloads.pdf +151 -0
- data/site/build/site/en/forum.html +197 -0
- data/site/build/site/en/forum.pdf +151 -0
- data/site/build/site/en/geneticAlgorithms.html +591 -0
- data/site/build/site/en/geneticAlgorithms.pdf +934 -0
- data/site/build/site/en/images/ai4r-logo.png +0 -0
- data/site/build/site/en/images/built-with-forrest-button.png +0 -0
- data/site/build/site/en/images/c.png +0 -0
- data/site/build/site/en/images/c_wbn.png +0 -0
- data/site/build/site/en/images/c_wn.png +0 -0
- data/site/build/site/en/images/ero.gif +0 -0
- data/site/build/site/en/images/europe2.png +0 -0
- data/site/build/site/en/images/europe3.png +0 -0
- data/site/build/site/en/images/fitness.png +0 -0
- data/site/build/site/en/images/genetic_algorithms_example.png +0 -0
- data/site/build/site/en/images/instruction_arrow.png +0 -0
- data/site/build/site/en/images/jadeferret.png +0 -0
- data/site/build/site/en/images/my_email.png +0 -0
- data/site/build/site/en/images/neural_network_example.png +0 -0
- data/site/build/site/en/images/rubyforge.png +0 -0
- data/site/build/site/en/images/s.png +0 -0
- data/site/build/site/en/images/s_wbn.png +0 -0
- data/site/build/site/en/images/s_wn.png +0 -0
- data/site/build/site/en/images/sigmoid.png +0 -0
- data/site/build/site/en/images/t.png +0 -0
- data/site/build/site/en/images/t_wbn.png +0 -0
- data/site/build/site/en/images/t_wn.png +0 -0
- data/site/build/site/en/index.html +336 -0
- data/site/build/site/en/index.pdf +508 -0
- data/site/build/site/en/linkmap.html +263 -0
- data/site/build/site/en/linkmap.pdf +94 -0
- data/site/build/site/en/locationmap.xml +72 -0
- data/site/build/site/en/machineLearning.html +339 -0
- data/site/build/site/en/machineLearning.pdf +337 -0
- data/site/build/site/en/neuralNetworks.html +484 -0
- data/site/build/site/en/neuralNetworks.pdf +604 -0
- data/site/build/site/en/skin/CommonMessages_de.xml +23 -0
- data/site/build/site/en/skin/CommonMessages_en_US.xml +23 -0
- data/site/build/site/en/skin/CommonMessages_es.xml +23 -0
- data/site/build/site/en/skin/CommonMessages_fr.xml +23 -0
- data/site/build/site/en/skin/basic.css +166 -0
- data/site/build/site/en/skin/breadcrumbs-optimized.js +90 -0
- data/site/build/site/en/skin/breadcrumbs.js +237 -0
- data/site/build/site/en/skin/fontsize.js +166 -0
- data/site/build/site/en/skin/getBlank.js +40 -0
- data/site/build/site/en/skin/getMenu.js +45 -0
- data/site/build/site/en/skin/images/README.txt +1 -0
- data/site/build/site/en/skin/images/add.jpg +0 -0
- data/site/build/site/en/skin/images/built-with-forrest-button.png +0 -0
- data/site/build/site/en/skin/images/chapter.gif +0 -0
- data/site/build/site/en/skin/images/chapter_open.gif +0 -0
- data/site/build/site/en/skin/images/current.gif +0 -0
- data/site/build/site/en/skin/images/error.png +0 -0
- data/site/build/site/en/skin/images/external-link.gif +0 -0
- data/site/build/site/en/skin/images/fix.jpg +0 -0
- data/site/build/site/en/skin/images/forrest-credit-logo.png +0 -0
- data/site/build/site/en/skin/images/hack.jpg +0 -0
- data/site/build/site/en/skin/images/header_white_line.gif +0 -0
- data/site/build/site/en/skin/images/info.png +0 -0
- data/site/build/site/en/skin/images/instruction_arrow.png +0 -0
- data/site/build/site/en/skin/images/label.gif +0 -0
- data/site/build/site/en/skin/images/page.gif +0 -0
- data/site/build/site/en/skin/images/pdfdoc.gif +0 -0
- data/site/build/site/en/skin/images/poddoc.png +0 -0
- data/site/build/site/en/skin/images/printer.gif +0 -0
- data/site/build/site/en/skin/images/rc-b-l-15-1body-2menu-3menu.png +0 -0
- data/site/build/site/en/skin/images/rc-b-r-15-1body-2menu-3menu.png +0 -0
- data/site/build/site/en/skin/images/rc-b-r-5-1header-2tab-selected-3tab-selected.png +0 -0
- data/site/build/site/en/skin/images/rc-t-l-5-1header-2searchbox-3searchbox.png +0 -0
- data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-selected-3tab-selected.png +0 -0
- data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-unselected-3tab-unselected.png +0 -0
- data/site/build/site/en/skin/images/rc-t-r-15-1body-2menu-3menu.png +0 -0
- data/site/build/site/en/skin/images/rc-t-r-5-1header-2searchbox-3searchbox.png +0 -0
- data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-selected-3tab-selected.png +0 -0
- data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-unselected-3tab-unselected.png +0 -0
- data/site/build/site/en/skin/images/remove.jpg +0 -0
- data/site/build/site/en/skin/images/rss.png +0 -0
- data/site/build/site/en/skin/images/spacer.gif +0 -0
- data/site/build/site/en/skin/images/success.png +0 -0
- data/site/build/site/en/skin/images/txtdoc.png +0 -0
- data/site/build/site/en/skin/images/update.jpg +0 -0
- data/site/build/site/en/skin/images/valid-html401.png +0 -0
- data/site/build/site/en/skin/images/vcss.png +0 -0
- data/site/build/site/en/skin/images/warning.png +0 -0
- data/site/build/site/en/skin/images/xmldoc.gif +0 -0
- data/site/build/site/en/skin/menu.js +48 -0
- data/site/build/site/en/skin/note.txt +50 -0
- data/site/build/site/en/skin/print.css +54 -0
- data/site/build/site/en/skin/profile.css +163 -0
- data/site/build/site/en/skin/prototype.js +1257 -0
- data/site/build/site/en/skin/screen.css +587 -0
- data/site/build/site/en/svn.html +252 -0
- data/site/build/site/en/svn.pdf +306 -0
- data/site/build/site/en/wholesite.pdf +1915 -0
- data/site/build/tmp/brokenlinks.xml +2 -0
- data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.data +0 -0
- data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.index +0 -0
- data/site/build/tmp/locationmap.xml +14 -14
- data/site/build/tmp/output.xmap +23 -23
- data/site/build/tmp/pluginlist2fetchbuild.xml +144 -144
- data/site/build/tmp/projfilters.properties +41 -41
- data/site/build/webapp/WEB-INF/logs/core.log +593 -679
- data/site/build/webapp/WEB-INF/logs/error.log +362 -279
- data/site/build/webapp/WEB-INF/logs/sitemap.log +368 -1015
- data/site/src/documentation/content/xdocs/index.xml +18 -10
- data/site/src/documentation/content/xdocs/machineLearning.xml +4 -3
- data/site/src/documentation/content/xdocs/site.xml +2 -1
- data/site/src/documentation/resources/images/sigmoid.png +0 -0
- data/test/classifiers/id3_test.rb +45 -44
- data/test/classifiers/one_r_test.rb +19 -17
- data/test/classifiers/prism_test.rb +22 -20
- data/test/classifiers/zero_r_test.rb +15 -12
- data/test/clusterers/bisecting_k_means_test.rb +59 -0
- data/test/clusterers/k_means_test.rb +93 -0
- data/test/data/data_set_test.rb +92 -0
- metadata +252 -128
- data/lib/ai4r/classifiers/classifier_helper.rb +0 -54
- data/site/src/documentation/content/xdocs/forum.html +0 -9
- data/site/src/documentation/resources/images/Thumbs.db +0 -0
- data/site/src/documentation/resources/images/sub-dir/Thumbs.db +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
5
|
+
<meta content="Apache Forrest" name="Generator">
|
|
6
|
+
<meta name="Forrest-version" content="0.8">
|
|
7
|
+
<meta name="Forrest-skin-name" content="pelt">
|
|
8
|
+
<title>Site Linkmap Table of Contents</title>
|
|
9
|
+
<link type="text/css" href="skin/basic.css" rel="stylesheet">
|
|
10
|
+
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
|
|
11
|
+
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
|
|
12
|
+
<link type="text/css" href="skin/profile.css" rel="stylesheet">
|
|
13
|
+
<script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
|
|
14
|
+
<link rel="shortcut icon" href="">
|
|
15
|
+
</head>
|
|
16
|
+
<body onload="init()">
|
|
17
|
+
<script type="text/javascript">ndeSetTextSize();</script>
|
|
18
|
+
<div id="top">
|
|
19
|
+
<!--+
|
|
20
|
+
|header
|
|
21
|
+
+-->
|
|
22
|
+
<div class="header">
|
|
23
|
+
<!--+
|
|
24
|
+
|start group logo
|
|
25
|
+
+-->
|
|
26
|
+
<div class="grouplogo">
|
|
27
|
+
<a href="http://www.jadeferret.com"><img class="logoImage" alt="Jade Ferret" src="images/jadeferret.png" title="Jade Ferret"></a>
|
|
28
|
+
</div>
|
|
29
|
+
<!--+
|
|
30
|
+
|end group logo
|
|
31
|
+
+-->
|
|
32
|
+
<!--+
|
|
33
|
+
|start Project Logo
|
|
34
|
+
+-->
|
|
35
|
+
<div class="projectlogo">
|
|
36
|
+
<a href="http://ai4r.rubyforge.org/"><img class="logoImage" alt="ai4r" src="images/ai4r-logo.png" title="AI4R - Artificial Intelligence for Ruby"></a>
|
|
37
|
+
</div>
|
|
38
|
+
<!--+
|
|
39
|
+
|end Project Logo
|
|
40
|
+
+-->
|
|
41
|
+
<!--+
|
|
42
|
+
|start Search
|
|
43
|
+
+-->
|
|
44
|
+
<div class="searchbox">
|
|
45
|
+
<div class="roundtopsmall">
|
|
46
|
+
<form target="_top" action="http://www.google.com/custom" method="get">
|
|
47
|
+
<input value="ai4r.rubyforge.org;raa.ruby-lang.org;rubyforge.org" name="domains" type="hidden"><label style="display: none" for="sbi">Enter your search terms</label><input id="sbi" value="" maxlength="255" size="31" name="q" type="text"><label style="display: none" for="sbb">Submit search form</label><input id="sbb" value="Search" name="sa" type="submit"><span style="display:none"><input id="ss0" value="" name="sitesearch" style="display=none" type="radio"><input id="ss1" checked value="ai4r.rubyforge.org" name="sitesearch" style="display=none" type="radio"><input id="ss2" value="raa.ruby-lang.org" name="sitesearch" style="display=none" type="radio"><input id="ss3" value="rubyforge.org" name="sitesearch" style="display=none" type="radio"></span><input value="pub-2578934938711895" name="client" type="hidden"><input value="1" name="forid" type="hidden"><input value="ISO-8859-1" name="ie" type="hidden"><input value="ISO-8859-1" name="oe" type="hidden"><input value="active" name="safe" type="hidden"><input value="0000" name="flav" type="hidden"><input value="XEZZoGuMPMQqvUG_" name="sig" type="hidden"><input value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:78;L:http://ai4r.rubyforge.org/images/ai4r-logo.png;S:http://ai4r.rubyforge.org/;FORID:1" name="cof" type="hidden"><input value="en" name="hl" type="hidden">
|
|
48
|
+
</form>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<!--+
|
|
52
|
+
|end search
|
|
53
|
+
+-->
|
|
54
|
+
<!--+
|
|
55
|
+
|start Tabs
|
|
56
|
+
+-->
|
|
57
|
+
<ul id="tabs">
|
|
58
|
+
<li class="current">
|
|
59
|
+
<a class="selected" href="index.html">Home</a>
|
|
60
|
+
</li>
|
|
61
|
+
</ul>
|
|
62
|
+
<!--+
|
|
63
|
+
|end Tabs
|
|
64
|
+
+-->
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div id="main">
|
|
68
|
+
<div id="publishedStrip">
|
|
69
|
+
<!--+
|
|
70
|
+
|start Subtabs
|
|
71
|
+
+-->
|
|
72
|
+
<div id="level2tabs"></div>
|
|
73
|
+
<!--+
|
|
74
|
+
|end Endtabs
|
|
75
|
+
+-->
|
|
76
|
+
<script type="text/javascript"><!--
|
|
77
|
+
document.write("Last Published: " + document.lastModified);
|
|
78
|
+
// --></script>
|
|
79
|
+
</div>
|
|
80
|
+
<!--+
|
|
81
|
+
|breadtrail
|
|
82
|
+
+-->
|
|
83
|
+
<div class="breadtrail">
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
<!--+
|
|
88
|
+
|start Menu, mainarea
|
|
89
|
+
+-->
|
|
90
|
+
<!--+
|
|
91
|
+
|start Menu
|
|
92
|
+
+-->
|
|
93
|
+
<div id="menu">
|
|
94
|
+
<div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Home</div>
|
|
95
|
+
<div id="menu_1.1" class="menuitemgroup">
|
|
96
|
+
<div class="menuitem">
|
|
97
|
+
<a href="index.html" title="ai4r - Artificial Intelligence for Ruby">Index</a>
|
|
98
|
+
</div>
|
|
99
|
+
<div onclick="SwitchMenu('menu_1.1.2', 'skin/')" id="menu_1.1.2Title" class="menutitle">Practical Examples</div>
|
|
100
|
+
<div id="menu_1.1.2" class="menuitemgroup">
|
|
101
|
+
<div class="menuitem">
|
|
102
|
+
<a href="geneticAlgorithms.html" title="Genetic Algorithms in ruby">Genetic Algorithms</a>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="menuitem">
|
|
105
|
+
<a href="machineLearning.html" title="ID3 Decision Trees in ruby">Machine Learning</a>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="menuitem">
|
|
108
|
+
<a href="neuralNetworks.html" title="Backpropagation Neural Network in ruby">Neural Networks</a>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="menuitem">
|
|
112
|
+
<a href="downloads.html" title="ai4r - Download Files">Downloads</a>
|
|
113
|
+
</div>
|
|
114
|
+
<div class="menuitem">
|
|
115
|
+
<a href="http://forum.jadeferret.com/viewforum.php?f=3" title="Ai4r Forum">Forum</a>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="menuitem">
|
|
118
|
+
<a href="http://ai4r.rubyforge.org/rdoc/index.html" title="Ai4 RDoc docs">API doc (Rdoc)</a>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="menuitem">
|
|
121
|
+
<a href="svn.html" title="ai4r Subversion repository">Source Code repository</a>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="menuitem">
|
|
124
|
+
<a href="wholesite.pdf">ai4r project PDF</a>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div id="credit">
|
|
128
|
+
<script type="text/javascript">
|
|
129
|
+
google_ad_client = "pub-2578934938711895";
|
|
130
|
+
google_ad_slot = "6111091580";
|
|
131
|
+
google_ad_width = 125;
|
|
132
|
+
google_ad_height = 125;
|
|
133
|
+
</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
|
|
134
|
+
<hr>
|
|
135
|
+
</div>
|
|
136
|
+
<div id="roundbottom">
|
|
137
|
+
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
|
|
138
|
+
<!--+
|
|
139
|
+
|alternative credits
|
|
140
|
+
+-->
|
|
141
|
+
<div id="credit2"></div>
|
|
142
|
+
</div>
|
|
143
|
+
<!--+
|
|
144
|
+
|end Menu
|
|
145
|
+
+-->
|
|
146
|
+
<!--+
|
|
147
|
+
|start content
|
|
148
|
+
+-->
|
|
149
|
+
<div id="content">
|
|
150
|
+
<div title="Portable Document Format" class="pdflink">
|
|
151
|
+
<a class="dida" href="linkmap.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
|
|
152
|
+
PDF</a>
|
|
153
|
+
</div>
|
|
154
|
+
<h1>Site Linkmap Table of Contents</h1>
|
|
155
|
+
<p>
|
|
156
|
+
This is a map of the complete site and its structure.
|
|
157
|
+
</p>
|
|
158
|
+
<ul>
|
|
159
|
+
<li>
|
|
160
|
+
<a>ai4r</a> ___________________ <em>site</em>
|
|
161
|
+
</li>
|
|
162
|
+
<ul>
|
|
163
|
+
|
|
164
|
+
<ul>
|
|
165
|
+
<li>
|
|
166
|
+
<a>Home</a> ___________________ <em>about</em>
|
|
167
|
+
</li>
|
|
168
|
+
<ul>
|
|
169
|
+
|
|
170
|
+
<ul>
|
|
171
|
+
<li>
|
|
172
|
+
<a href="index.html">Index</a> ___________________ <em>index</em> : ai4r - Artificial Intelligence for Ruby</li>
|
|
173
|
+
</ul>
|
|
174
|
+
|
|
175
|
+
<ul>
|
|
176
|
+
<li>
|
|
177
|
+
<a>Practical Examples</a> ___________________ <em>practicalExamples</em>
|
|
178
|
+
</li>
|
|
179
|
+
<ul>
|
|
180
|
+
|
|
181
|
+
<ul>
|
|
182
|
+
<li>
|
|
183
|
+
<a href="geneticAlgorithms.html">Genetic Algorithms</a> ___________________ <em>geneticAlgorithms</em> : Genetic Algorithms in ruby</li>
|
|
184
|
+
</ul>
|
|
185
|
+
|
|
186
|
+
<ul>
|
|
187
|
+
<li>
|
|
188
|
+
<a href="machineLearning.html">Machine Learning</a> ___________________ <em>machineLearning</em> : ID3 Decision Trees in ruby</li>
|
|
189
|
+
</ul>
|
|
190
|
+
|
|
191
|
+
<ul>
|
|
192
|
+
<li>
|
|
193
|
+
<a href="neuralNetworks.html">Neural Networks</a> ___________________ <em>neuralNetworks</em> : Backpropagation Neural Network in ruby</li>
|
|
194
|
+
</ul>
|
|
195
|
+
|
|
196
|
+
</ul>
|
|
197
|
+
</ul>
|
|
198
|
+
|
|
199
|
+
<ul>
|
|
200
|
+
<li>
|
|
201
|
+
<a href="downloads.html">Downloads</a> ___________________ <em>download</em> : ai4r - Download Files</li>
|
|
202
|
+
</ul>
|
|
203
|
+
|
|
204
|
+
<ul>
|
|
205
|
+
<li>
|
|
206
|
+
<a class="external" href="http://forum.jadeferret.com/viewforum.php?f=3">Forum</a> ___________________ <em>forum</em> : Ai4r Forum</li>
|
|
207
|
+
</ul>
|
|
208
|
+
|
|
209
|
+
<ul>
|
|
210
|
+
<li>
|
|
211
|
+
<a href="http://ai4r.rubyforge.org/rdoc/index.html">API doc (Rdoc)</a> ___________________ <em>rdoc</em> : Ai4 RDoc docs</li>
|
|
212
|
+
</ul>
|
|
213
|
+
|
|
214
|
+
<ul>
|
|
215
|
+
<li>
|
|
216
|
+
<a href="svn.html">Source Code repository</a> ___________________ <em>svn</em> : ai4r Subversion repository</li>
|
|
217
|
+
</ul>
|
|
218
|
+
|
|
219
|
+
<ul>
|
|
220
|
+
<li>
|
|
221
|
+
<a href="wholesite.pdf">ai4r project PDF</a> ___________________ <em>ai4r_site_pdf</em>
|
|
222
|
+
</li>
|
|
223
|
+
</ul>
|
|
224
|
+
|
|
225
|
+
</ul>
|
|
226
|
+
</ul>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
</ul>
|
|
230
|
+
</ul>
|
|
231
|
+
</div>
|
|
232
|
+
<!--+
|
|
233
|
+
|end content
|
|
234
|
+
+-->
|
|
235
|
+
<div class="clearboth"> </div>
|
|
236
|
+
</div>
|
|
237
|
+
<div id="footer">
|
|
238
|
+
<!--+
|
|
239
|
+
|start bottomstrip
|
|
240
|
+
+-->
|
|
241
|
+
<div class="lastmodified">
|
|
242
|
+
<script type="text/javascript"><!--
|
|
243
|
+
document.write("Last Published: " + document.lastModified);
|
|
244
|
+
// --></script>
|
|
245
|
+
</div>
|
|
246
|
+
<div class="copyright">
|
|
247
|
+
Copyright ©
|
|
248
|
+
2007-2009 <a href="http://www.jadeferret.com/">Sergio Fierens, Jade Ferret</a>
|
|
249
|
+
</div>
|
|
250
|
+
<div class="host">
|
|
251
|
+
<a href="http://rubyforge.org/projects/ai4r/"><img class="logoImage" alt="" src="images/rubyforge.png"></a>
|
|
252
|
+
</div>
|
|
253
|
+
<!--+
|
|
254
|
+
|end bottomstrip
|
|
255
|
+
+-->
|
|
256
|
+
</div>
|
|
257
|
+
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
|
|
258
|
+
var pageTracker = _gat._getTracker("UA-3234625-1");
|
|
259
|
+
pageTracker._initData();
|
|
260
|
+
pageTracker._trackPageview();
|
|
261
|
+
</script>
|
|
262
|
+
</body>
|
|
263
|
+
</html>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
%PDF-1.3
|
|
2
|
+
%����
|
|
3
|
+
4 0 obj
|
|
4
|
+
<< /Type /Info
|
|
5
|
+
/Producer (FOP 0.20.5) >>
|
|
6
|
+
endobj
|
|
7
|
+
5 0 obj
|
|
8
|
+
<< /Length 1145 /Filter [ /ASCII85Decode /FlateDecode ]
|
|
9
|
+
>>
|
|
10
|
+
stream
|
|
11
|
+
Gat=+fi$QY'Re;/p^q+qX2XYH>9K^N6Q&MeeoVbL<ZDjp8nEe>mjm-a,ag&J9kUE-N:&_#kUuSZD")S+*TXcHR4SZ:r\#,h-Q>;UaFDQnl94#,0(qYF[W[+j9j'p2SI6-bo#]Q*/"YA_7W$B/7BSf:9=;Lr77E-74El69ZWi8[*/Id/"-*M8lN=>ES#odq]--d11OU:Ejc2WB[#j[d>#AiVI(dX9V<sL@\)JU^O=C^>XMd#r[Xu'qma/hA6uE_,\Bba2-\@&FQA,+Lp%HeQbS(VTJ-P`3j3PQ4s1o^"aRsu1?Q5Z/!V1"1*cquJ3+"r'7fJs^Bl?=8jC/glro41><i7AAo`d_Q[tW8+8Ej>c:)IK_aYNs"ld<i]926?#k+PF"ES=XO=Vkg5'GXiXKZ1LUS&cepF-b2td;j0I`K%`"Lp4uKR3UZ3no;9dn,?<3QPW,k@QJNmLcDA9U/SRIMsEt`H]&_pN?/;jAri_"gFkRe1Z&SI9^T(`7LL]ZBi=(2(T^fBHaEFMmm[mE@C$_>pMOP::`sO81`]hE/d0#%Uc]9gPWp23^>BW>/WSV-Wu)>KAaq!?<ijYGlAilY?q&XR0A6"aBS*Bk']n)P(6iS0S`:Knj8_4dq.,.Y$mV4FP&X3cR@s2eAHTkS*qsb,o\-gQeLMH^rNf2;d\s$Q((H(?D&3Xh2[Xs(oPr8tKN&^n`Q@^@n4fFlPp)J?][$u<oG8KTl\$,Ff-9Btg:s,uJL0KFJW]AjSrh*IYflAh/U;I-]\aS_eZ:f?'@0j"@kP4Ur_obt#m4SgH9<p9A@E#0Gt8<gBS8M!]QKsc>.&LI)EpiZMj/!?COYt*mJ2%rO@.[5(`DP3JZrK9O<$D>O-fquj)Lm$Q$t;d$LOs'b-s^0ak&Z*/3u4"^.r\<hRbY\W#;'/L[q9$V#[YG/M`AhdsS`4]MR#Lb9QHg(hapW&*JaD.(!'g#qF]T+.?/Dj'ae4T-U3Md0=n+pJeoK5&Ja0mdSJ;n@/3gBjS@o#i'sOTj&JO7Doef=UoljY3PHp,bOP?DaG._7/OWJEg0';E?ab4TS:#?Rs2]S<M_lak(l96+TMRT9rZ2N=8&"Y6&Y;lg:<2Am=T(GKqOn'@@f!E_(@O6Q;kNDe5]rW"+`m"o)~>
|
|
12
|
+
endstream
|
|
13
|
+
endobj
|
|
14
|
+
6 0 obj
|
|
15
|
+
<< /Type /Page
|
|
16
|
+
/Parent 1 0 R
|
|
17
|
+
/MediaBox [ 0 0 612 792 ]
|
|
18
|
+
/Resources 3 0 R
|
|
19
|
+
/Contents 5 0 R
|
|
20
|
+
>>
|
|
21
|
+
endobj
|
|
22
|
+
7 0 obj
|
|
23
|
+
<< /Type /Font
|
|
24
|
+
/Subtype /Type1
|
|
25
|
+
/Name /F3
|
|
26
|
+
/BaseFont /Helvetica-Bold
|
|
27
|
+
/Encoding /WinAnsiEncoding >>
|
|
28
|
+
endobj
|
|
29
|
+
8 0 obj
|
|
30
|
+
<< /Type /Font
|
|
31
|
+
/Subtype /Type1
|
|
32
|
+
/Name /F5
|
|
33
|
+
/BaseFont /Times-Roman
|
|
34
|
+
/Encoding /WinAnsiEncoding >>
|
|
35
|
+
endobj
|
|
36
|
+
9 0 obj
|
|
37
|
+
<< /Type /Font
|
|
38
|
+
/Subtype /Type1
|
|
39
|
+
/Name /F6
|
|
40
|
+
/BaseFont /Times-Italic
|
|
41
|
+
/Encoding /WinAnsiEncoding >>
|
|
42
|
+
endobj
|
|
43
|
+
10 0 obj
|
|
44
|
+
<< /Type /Font
|
|
45
|
+
/Subtype /Type1
|
|
46
|
+
/Name /F1
|
|
47
|
+
/BaseFont /Helvetica
|
|
48
|
+
/Encoding /WinAnsiEncoding >>
|
|
49
|
+
endobj
|
|
50
|
+
11 0 obj
|
|
51
|
+
<< /Type /Font
|
|
52
|
+
/Subtype /Type1
|
|
53
|
+
/Name /F2
|
|
54
|
+
/BaseFont /Helvetica-Oblique
|
|
55
|
+
/Encoding /WinAnsiEncoding >>
|
|
56
|
+
endobj
|
|
57
|
+
1 0 obj
|
|
58
|
+
<< /Type /Pages
|
|
59
|
+
/Count 1
|
|
60
|
+
/Kids [6 0 R ] >>
|
|
61
|
+
endobj
|
|
62
|
+
2 0 obj
|
|
63
|
+
<< /Type /Catalog
|
|
64
|
+
/Pages 1 0 R
|
|
65
|
+
>>
|
|
66
|
+
endobj
|
|
67
|
+
3 0 obj
|
|
68
|
+
<<
|
|
69
|
+
/Font << /F3 7 0 R /F5 8 0 R /F1 10 0 R /F6 9 0 R /F2 11 0 R >>
|
|
70
|
+
/ProcSet [ /PDF /ImageC /Text ] >>
|
|
71
|
+
endobj
|
|
72
|
+
xref
|
|
73
|
+
0 12
|
|
74
|
+
0000000000 65535 f
|
|
75
|
+
0000001969 00000 n
|
|
76
|
+
0000002027 00000 n
|
|
77
|
+
0000002077 00000 n
|
|
78
|
+
0000000015 00000 n
|
|
79
|
+
0000000071 00000 n
|
|
80
|
+
0000001308 00000 n
|
|
81
|
+
0000001414 00000 n
|
|
82
|
+
0000001526 00000 n
|
|
83
|
+
0000001635 00000 n
|
|
84
|
+
0000001745 00000 n
|
|
85
|
+
0000001853 00000 n
|
|
86
|
+
trailer
|
|
87
|
+
<<
|
|
88
|
+
/Size 12
|
|
89
|
+
/Root 2 0 R
|
|
90
|
+
/Info 4 0 R
|
|
91
|
+
>>
|
|
92
|
+
startxref
|
|
93
|
+
2197
|
|
94
|
+
%%EOF
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
|
5
|
+
this work for additional information regarding copyright ownership.
|
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
|
8
|
+
the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
See the License for the specific language governing permissions and
|
|
16
|
+
limitations under the License.
|
|
17
|
+
-->
|
|
18
|
+
<locationmap xmlns="http://apache.org/forrest/locationmap/1.0">
|
|
19
|
+
<components>
|
|
20
|
+
<matchers default="lm">
|
|
21
|
+
<matcher name="lm" src="org.apache.forrest.locationmap.WildcardLocationMapHintMatcher"/>
|
|
22
|
+
</matchers>
|
|
23
|
+
<!--
|
|
24
|
+
* Can contain any sitemap selector with the following syntax. *
|
|
25
|
+
<selectors default="exists">
|
|
26
|
+
<selector name="exists" logger="sitemap.selector.exists"
|
|
27
|
+
src="org.apache.forrest.sourceexists.SourceExistsSelector" />
|
|
28
|
+
</selectors>
|
|
29
|
+
-->
|
|
30
|
+
</components>
|
|
31
|
+
<!--
|
|
32
|
+
* Can contain a mount statement as a sibling to components and locator *
|
|
33
|
+
<mount src="somelocation.xml"/>
|
|
34
|
+
-->
|
|
35
|
+
<locator>
|
|
36
|
+
<!--
|
|
37
|
+
* Can contain a mount within a selector where a selector is valid.
|
|
38
|
+
<select>
|
|
39
|
+
<mount src="somelocation.xml"/>
|
|
40
|
+
</select>
|
|
41
|
+
-->
|
|
42
|
+
<match pattern="project.rewrite.**">
|
|
43
|
+
<location src="http://cocoon.apache.org/{1}.html"/>
|
|
44
|
+
</match>
|
|
45
|
+
<match pattern="project.remote.**.xml">
|
|
46
|
+
<location src="http://svn.apache.org/repos/asf/forrest/trunk/main/fresh-site/src/documentation/content/xdocs/{1}.xml"/>
|
|
47
|
+
</match>
|
|
48
|
+
<!--
|
|
49
|
+
* Can use a selector inside a match. *
|
|
50
|
+
<match pattern="somepattern/**">
|
|
51
|
+
<select>
|
|
52
|
+
<location src="first-location-attempted"/>
|
|
53
|
+
<location src="second-location-attempted"/>
|
|
54
|
+
<location src="third-location-attepted"/>
|
|
55
|
+
</select>
|
|
56
|
+
</match>
|
|
57
|
+
-->
|
|
58
|
+
<!--
|
|
59
|
+
To locate all your source documents in a slide repository you can do:
|
|
60
|
+
|
|
61
|
+
<match pattern="tabs.xml">
|
|
62
|
+
<location src="http://127.0.0.1:8080/slide/files/tabs.xml"/>
|
|
63
|
+
</match>
|
|
64
|
+
<match pattern="site.xml">
|
|
65
|
+
<location src="http://127.0.0.1:8080/slide/files/site.xml"/>
|
|
66
|
+
</match>
|
|
67
|
+
<match pattern="**.xml">
|
|
68
|
+
<location src="http://127.0.0.1:8080/slide/files/{1}.xml"/>
|
|
69
|
+
</match>
|
|
70
|
+
-->
|
|
71
|
+
</locator>
|
|
72
|
+
</locationmap>
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
5
|
+
<meta content="Apache Forrest" name="Generator">
|
|
6
|
+
<meta name="Forrest-version" content="0.8">
|
|
7
|
+
<meta name="Forrest-skin-name" content="pelt">
|
|
8
|
+
<title>Machine Learning with ID3 Decision Trees in Ruby</title>
|
|
9
|
+
<link type="text/css" href="skin/basic.css" rel="stylesheet">
|
|
10
|
+
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
|
|
11
|
+
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
|
|
12
|
+
<link type="text/css" href="skin/profile.css" rel="stylesheet">
|
|
13
|
+
<script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
|
|
14
|
+
<link rel="shortcut icon" href="">
|
|
15
|
+
</head>
|
|
16
|
+
<body onload="init()">
|
|
17
|
+
<script type="text/javascript">ndeSetTextSize();</script>
|
|
18
|
+
<div id="top">
|
|
19
|
+
<!--+
|
|
20
|
+
|header
|
|
21
|
+
+-->
|
|
22
|
+
<div class="header">
|
|
23
|
+
<!--+
|
|
24
|
+
|start group logo
|
|
25
|
+
+-->
|
|
26
|
+
<div class="grouplogo">
|
|
27
|
+
<a href="http://www.jadeferret.com"><img class="logoImage" alt="Jade Ferret" src="images/jadeferret.png" title="Jade Ferret"></a>
|
|
28
|
+
</div>
|
|
29
|
+
<!--+
|
|
30
|
+
|end group logo
|
|
31
|
+
+-->
|
|
32
|
+
<!--+
|
|
33
|
+
|start Project Logo
|
|
34
|
+
+-->
|
|
35
|
+
<div class="projectlogo">
|
|
36
|
+
<a href="http://ai4r.rubyforge.org/"><img class="logoImage" alt="ai4r" src="images/ai4r-logo.png" title="AI4R - Artificial Intelligence for Ruby"></a>
|
|
37
|
+
</div>
|
|
38
|
+
<!--+
|
|
39
|
+
|end Project Logo
|
|
40
|
+
+-->
|
|
41
|
+
<!--+
|
|
42
|
+
|start Search
|
|
43
|
+
+-->
|
|
44
|
+
<div class="searchbox">
|
|
45
|
+
<div class="roundtopsmall">
|
|
46
|
+
<form target="_top" action="http://www.google.com/custom" method="get">
|
|
47
|
+
<input value="ai4r.rubyforge.org;raa.ruby-lang.org;rubyforge.org" name="domains" type="hidden"><label style="display: none" for="sbi">Enter your search terms</label><input id="sbi" value="" maxlength="255" size="31" name="q" type="text"><label style="display: none" for="sbb">Submit search form</label><input id="sbb" value="Search" name="sa" type="submit"><span style="display:none"><input id="ss0" value="" name="sitesearch" style="display=none" type="radio"><input id="ss1" checked value="ai4r.rubyforge.org" name="sitesearch" style="display=none" type="radio"><input id="ss2" value="raa.ruby-lang.org" name="sitesearch" style="display=none" type="radio"><input id="ss3" value="rubyforge.org" name="sitesearch" style="display=none" type="radio"></span><input value="pub-2578934938711895" name="client" type="hidden"><input value="1" name="forid" type="hidden"><input value="ISO-8859-1" name="ie" type="hidden"><input value="ISO-8859-1" name="oe" type="hidden"><input value="active" name="safe" type="hidden"><input value="0000" name="flav" type="hidden"><input value="XEZZoGuMPMQqvUG_" name="sig" type="hidden"><input value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:78;L:http://ai4r.rubyforge.org/images/ai4r-logo.png;S:http://ai4r.rubyforge.org/;FORID:1" name="cof" type="hidden"><input value="en" name="hl" type="hidden">
|
|
48
|
+
</form>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<!--+
|
|
52
|
+
|end search
|
|
53
|
+
+-->
|
|
54
|
+
<!--+
|
|
55
|
+
|start Tabs
|
|
56
|
+
+-->
|
|
57
|
+
<ul id="tabs">
|
|
58
|
+
<li class="current">
|
|
59
|
+
<a class="selected" href="index.html">Home</a>
|
|
60
|
+
</li>
|
|
61
|
+
</ul>
|
|
62
|
+
<!--+
|
|
63
|
+
|end Tabs
|
|
64
|
+
+-->
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div id="main">
|
|
68
|
+
<div id="publishedStrip">
|
|
69
|
+
<!--+
|
|
70
|
+
|start Subtabs
|
|
71
|
+
+-->
|
|
72
|
+
<div id="level2tabs"></div>
|
|
73
|
+
<!--+
|
|
74
|
+
|end Endtabs
|
|
75
|
+
+-->
|
|
76
|
+
<script type="text/javascript"><!--
|
|
77
|
+
document.write("Last Published: " + document.lastModified);
|
|
78
|
+
// --></script>
|
|
79
|
+
</div>
|
|
80
|
+
<!--+
|
|
81
|
+
|breadtrail
|
|
82
|
+
+-->
|
|
83
|
+
<div class="breadtrail">
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
<!--+
|
|
88
|
+
|start Menu, mainarea
|
|
89
|
+
+-->
|
|
90
|
+
<!--+
|
|
91
|
+
|start Menu
|
|
92
|
+
+-->
|
|
93
|
+
<div id="menu">
|
|
94
|
+
<div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Home</div>
|
|
95
|
+
<div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
|
|
96
|
+
<div class="menuitem">
|
|
97
|
+
<a href="index.html" title="ai4r - Artificial Intelligence for Ruby">Index</a>
|
|
98
|
+
</div>
|
|
99
|
+
<div onclick="SwitchMenu('menu_selected_1.1.2', 'skin/')" id="menu_selected_1.1.2Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Practical Examples</div>
|
|
100
|
+
<div id="menu_selected_1.1.2" class="selectedmenuitemgroup" style="display: block;">
|
|
101
|
+
<div class="menuitem">
|
|
102
|
+
<a href="geneticAlgorithms.html" title="Genetic Algorithms in ruby">Genetic Algorithms</a>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="menupage">
|
|
105
|
+
<div class="menupagetitle">Machine Learning</div>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="menuitem">
|
|
108
|
+
<a href="neuralNetworks.html" title="Backpropagation Neural Network in ruby">Neural Networks</a>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="menuitem">
|
|
112
|
+
<a href="downloads.html" title="ai4r - Download Files">Downloads</a>
|
|
113
|
+
</div>
|
|
114
|
+
<div class="menuitem">
|
|
115
|
+
<a href="http://forum.jadeferret.com/viewforum.php?f=3" title="Ai4r Forum">Forum</a>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="menuitem">
|
|
118
|
+
<a href="http://ai4r.rubyforge.org/rdoc/index.html" title="Ai4 RDoc docs">API doc (Rdoc)</a>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="menuitem">
|
|
121
|
+
<a href="svn.html" title="ai4r Subversion repository">Source Code repository</a>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="menuitem">
|
|
124
|
+
<a href="wholesite.pdf">ai4r project PDF</a>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div id="credit">
|
|
128
|
+
<script type="text/javascript">
|
|
129
|
+
google_ad_client = "pub-2578934938711895";
|
|
130
|
+
google_ad_slot = "6111091580";
|
|
131
|
+
google_ad_width = 125;
|
|
132
|
+
google_ad_height = 125;
|
|
133
|
+
</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
|
|
134
|
+
<hr>
|
|
135
|
+
</div>
|
|
136
|
+
<div id="roundbottom">
|
|
137
|
+
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
|
|
138
|
+
<!--+
|
|
139
|
+
|alternative credits
|
|
140
|
+
+-->
|
|
141
|
+
<div id="credit2"></div>
|
|
142
|
+
</div>
|
|
143
|
+
<!--+
|
|
144
|
+
|end Menu
|
|
145
|
+
+-->
|
|
146
|
+
<!--+
|
|
147
|
+
|start content
|
|
148
|
+
+-->
|
|
149
|
+
<div id="content">
|
|
150
|
+
<div title="Portable Document Format" class="pdflink">
|
|
151
|
+
<a class="dida" href="machineLearning.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
|
|
152
|
+
PDF</a>
|
|
153
|
+
</div>
|
|
154
|
+
<h1>Machine Learning with ID3 Decision Trees in Ruby</h1>
|
|
155
|
+
<div id="minitoc-area">
|
|
156
|
+
<ul class="minitoc">
|
|
157
|
+
<li>
|
|
158
|
+
<a href="#mach-intro">Introduction to ID3 algorithm</a>
|
|
159
|
+
</li>
|
|
160
|
+
<li>
|
|
161
|
+
<a href="#mach-HowTo">Marketing target strategy example using ID3 Decision Trees in Ruby</a>
|
|
162
|
+
</li>
|
|
163
|
+
<li>
|
|
164
|
+
<a href="#mach-dataload">Better data loading</a>
|
|
165
|
+
</li>
|
|
166
|
+
<li>
|
|
167
|
+
<a href="#mach-eval">A good tip for data evaluation</a>
|
|
168
|
+
</li>
|
|
169
|
+
<li>
|
|
170
|
+
<a href="#mach-more">More about ID3 and decision trees</a>
|
|
171
|
+
</li>
|
|
172
|
+
</ul>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<a name="N1000C"></a><a name="mach-intro"></a>
|
|
176
|
+
<h2 class="boxed">Introduction to ID3 algorithm</h2>
|
|
177
|
+
<div class="section">
|
|
178
|
+
<p>
|
|
179
|
+
AI4R implements the ID3 algorithm (Quinlan) as one of its automatic classifiers.
|
|
180
|
+
Given a set of preclassified examples, it builds a top-down
|
|
181
|
+
induction of decision tree, biased by the information gain and
|
|
182
|
+
entropy measure.
|
|
183
|
+
</p>
|
|
184
|
+
<p>
|
|
185
|
+
The good thing about this automatic learning method is that humans learns as well.
|
|
186
|
+
Unlike other AI techniques like neural networks, classifiers can
|
|
187
|
+
generate ruby code with if / else sentences. You
|
|
188
|
+
can use this to evaluate parameters on realtime, copy paste them in a
|
|
189
|
+
code, or just read them to learn about your problem domain.
|
|
190
|
+
</p>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<a name="N10019"></a><a name="mach-HowTo"></a>
|
|
195
|
+
<h2 class="boxed">Marketing target strategy example using ID3 Decision Trees in Ruby</h2>
|
|
196
|
+
<div class="section">
|
|
197
|
+
<p>Let's suppose that you are writting an application that must identify people as relevant marketing targets or not.
|
|
198
|
+
The only information that you have is a collection of examples, provided by a marketing survey:</p>
|
|
199
|
+
<pre class="code">
|
|
200
|
+
|
|
201
|
+
DATA_LABELS = [ 'city', 'age_range', 'gender', 'marketing_target' ]
|
|
202
|
+
|
|
203
|
+
DATA_SET = [
|
|
204
|
+
['New York', '<30', 'M', 'Y'],
|
|
205
|
+
['Chicago', '<30', 'M', 'Y'],
|
|
206
|
+
['Chicago', '<30', 'F', 'Y'],
|
|
207
|
+
['New York', '<30', 'M', 'Y'],
|
|
208
|
+
['New York', '<30', 'M', 'Y'],
|
|
209
|
+
['Chicago', '[30-50)', 'M', 'Y'],
|
|
210
|
+
['New York', '[30-50)', 'F', 'N'],
|
|
211
|
+
['Chicago', '[30-50)', 'F', 'Y'],
|
|
212
|
+
['New York', '[30-50)', 'F', 'N'],
|
|
213
|
+
['Chicago', '[50-80]', 'M', 'N'],
|
|
214
|
+
['New York', '[50-80]', 'F', 'N'],
|
|
215
|
+
['New York', '[50-80]', 'M', 'N'],
|
|
216
|
+
['Chicago', '[50-80]', 'M', 'N'],
|
|
217
|
+
['New York', '[50-80]', 'F', 'N'],
|
|
218
|
+
['Chicago', '>80', 'F', 'Y']
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
</pre>
|
|
222
|
+
<p>You can create an ID3 Decision tree to do the dirty job for you:</p>
|
|
223
|
+
<pre class="code">
|
|
224
|
+
|
|
225
|
+
id3 = ID3.new(DATA_SET, DATA_LABELS)
|
|
226
|
+
|
|
227
|
+
</pre>
|
|
228
|
+
<p>The Decision tree will automatically create the "rules" to parse new data,
|
|
229
|
+
and identify new posible marketing targets:</p>
|
|
230
|
+
<pre class="code">
|
|
231
|
+
|
|
232
|
+
id3.to_s
|
|
233
|
+
# => if age_range=='<30' then marketing_target='Y'
|
|
234
|
+
elsif age_range=='[30-50)' and city=='Chicago' then marketing_target='Y'
|
|
235
|
+
elsif age_range=='[30-50)' and city=='New York' then marketing_target='N'
|
|
236
|
+
elsif age_range=='[50-80]' then marketing_target='N'
|
|
237
|
+
elsif age_range=='>80' then marketing_target='Y'
|
|
238
|
+
else raise 'There was not enough information during training to do a proper induction for this data element' end
|
|
239
|
+
|
|
240
|
+
id3.eval(['New York', '<30', 'M'])
|
|
241
|
+
# => 'Y'
|
|
242
|
+
|
|
243
|
+
</pre>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
<a name="N10035"></a><a name="mach-dataload"></a>
|
|
248
|
+
<h2 class="boxed">Better data loading</h2>
|
|
249
|
+
<div class="section">
|
|
250
|
+
<p>
|
|
251
|
+
In real life you will use many more data training examples,
|
|
252
|
+
with more attributes.
|
|
253
|
+
Consider moving your data to an external CSV (comma separate values) file.
|
|
254
|
+
</p>
|
|
255
|
+
<pre class="code">
|
|
256
|
+
|
|
257
|
+
data_set = []
|
|
258
|
+
CSV::Reader.parse(File.open("#{File.dirname(__FILE__)}/data_set.csv", 'r')) do |row|
|
|
259
|
+
data_set << row
|
|
260
|
+
end
|
|
261
|
+
data_labels = data_set.shift
|
|
262
|
+
|
|
263
|
+
id3 = ID3.new(data_set, data_labels)
|
|
264
|
+
</pre>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
<a name="N10043"></a><a name="mach-eval"></a>
|
|
269
|
+
<h2 class="boxed">A good tip for data evaluation</h2>
|
|
270
|
+
<div class="section">
|
|
271
|
+
<p>
|
|
272
|
+
The ID3 class provides a method to evaluate new data.
|
|
273
|
+
</p>
|
|
274
|
+
<pre class="code">
|
|
275
|
+
|
|
276
|
+
id3.eval(['New York', '<30', 'M'])
|
|
277
|
+
# => 'Y'
|
|
278
|
+
</pre>
|
|
279
|
+
<p>
|
|
280
|
+
But instead of going through the tree every time, you can take advantage of the fact that the method "to_s" generates proper ruby code!
|
|
281
|
+
</p>
|
|
282
|
+
<pre class="code">
|
|
283
|
+
|
|
284
|
+
id3 = ID3.new(DATA_SET, DATA_LABELS)
|
|
285
|
+
age_range = '<30'
|
|
286
|
+
city = 'New York'
|
|
287
|
+
gender = 'M'
|
|
288
|
+
marketing_target = nil
|
|
289
|
+
eval id3.to_s
|
|
290
|
+
puts marketing_target
|
|
291
|
+
# => 'Y'
|
|
292
|
+
</pre>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
<a name="N10058"></a><a name="mach-more"></a>
|
|
297
|
+
<h2 class="boxed">More about ID3 and decision trees</h2>
|
|
298
|
+
<div class="section">
|
|
299
|
+
<p>
|
|
300
|
+
|
|
301
|
+
<a class="external" href="http://en.wikipedia.org/wiki/Decision_tree">Wikipedia article on Decision trees</a>
|
|
302
|
+
<a class="external" href="http://en.wikipedia.org/wiki/ID3_algorithm">Wikipedia article on ID3 Algorithm</a>
|
|
303
|
+
|
|
304
|
+
</p>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
</div>
|
|
308
|
+
<!--+
|
|
309
|
+
|end content
|
|
310
|
+
+-->
|
|
311
|
+
<div class="clearboth"> </div>
|
|
312
|
+
</div>
|
|
313
|
+
<div id="footer">
|
|
314
|
+
<!--+
|
|
315
|
+
|start bottomstrip
|
|
316
|
+
+-->
|
|
317
|
+
<div class="lastmodified">
|
|
318
|
+
<script type="text/javascript"><!--
|
|
319
|
+
document.write("Last Published: " + document.lastModified);
|
|
320
|
+
// --></script>
|
|
321
|
+
</div>
|
|
322
|
+
<div class="copyright">
|
|
323
|
+
Copyright ©
|
|
324
|
+
2007-2009 <a href="http://www.jadeferret.com/">Sergio Fierens, Jade Ferret</a>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="host">
|
|
327
|
+
<a href="http://rubyforge.org/projects/ai4r/"><img class="logoImage" alt="" src="images/rubyforge.png"></a>
|
|
328
|
+
</div>
|
|
329
|
+
<!--+
|
|
330
|
+
|end bottomstrip
|
|
331
|
+
+-->
|
|
332
|
+
</div>
|
|
333
|
+
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
|
|
334
|
+
var pageTracker = _gat._getTracker("UA-3234625-1");
|
|
335
|
+
pageTracker._initData();
|
|
336
|
+
pageTracker._trackPageview();
|
|
337
|
+
</script>
|
|
338
|
+
</body>
|
|
339
|
+
</html>
|