ai4r 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. data/README.rdoc +48 -0
  2. data/examples/decision_trees/data_set.csv +121 -0
  3. data/examples/decision_trees/id3_example.rb +31 -0
  4. data/examples/decision_trees/results.txt +29 -0
  5. data/examples/genetic_algorithm/genetic_algorithm_example.rb +39 -0
  6. data/examples/genetic_algorithm/travel_cost.csv +16 -0
  7. data/examples/neural_network/backpropagation_example.rb +65 -0
  8. data/examples/neural_network/patterns_with_base_noise.rb +68 -0
  9. data/examples/neural_network/patterns_with_noise.rb +66 -0
  10. data/examples/neural_network/training_patterns.rb +68 -0
  11. data/lib/decision_tree/id3.rb +354 -0
  12. data/lib/genetic_algorithm/genetic_algorithm.rb +268 -0
  13. data/lib/neural_network/backpropagation.rb +259 -0
  14. data/site/build/site/en/broken-links.xml +2 -0
  15. data/site/build/site/en/downloads.html +187 -0
  16. data/site/build/site/en/downloads.pdf +151 -0
  17. data/site/build/site/en/geneticAlgorithms.html +564 -0
  18. data/site/build/site/en/geneticAlgorithms.pdf +911 -0
  19. data/site/build/site/en/images/ai4r-logo.png +0 -0
  20. data/site/build/site/en/images/built-with-forrest-button.png +0 -0
  21. data/site/build/site/en/images/c.png +0 -0
  22. data/site/build/site/en/images/c_wbn.png +0 -0
  23. data/site/build/site/en/images/c_wn.png +0 -0
  24. data/site/build/site/en/images/ero.gif +0 -0
  25. data/site/build/site/en/images/europe2.png +0 -0
  26. data/site/build/site/en/images/europe3.png +0 -0
  27. data/site/build/site/en/images/fitness.png +0 -0
  28. data/site/build/site/en/images/instruction_arrow.png +0 -0
  29. data/site/build/site/en/images/my_email.png +0 -0
  30. data/site/build/site/en/images/rubyforge.png +0 -0
  31. data/site/build/site/en/images/s.png +0 -0
  32. data/site/build/site/en/images/s_wbn.png +0 -0
  33. data/site/build/site/en/images/s_wn.png +0 -0
  34. data/site/build/site/en/images/sigmoid.png +0 -0
  35. data/site/build/site/en/images/t.png +0 -0
  36. data/site/build/site/en/images/t_wbn.png +0 -0
  37. data/site/build/site/en/images/t_wn.png +0 -0
  38. data/site/build/site/en/index.html +258 -0
  39. data/site/build/site/en/index.pdf +306 -0
  40. data/site/build/site/en/linkmap.html +231 -0
  41. data/site/build/site/en/linkmap.pdf +94 -0
  42. data/site/build/site/en/locationmap.xml +72 -0
  43. data/site/build/site/en/machineLearning.html +325 -0
  44. data/site/build/site/en/machineLearning.pdf +337 -0
  45. data/site/build/site/en/neuralNetworks.html +446 -0
  46. data/site/build/site/en/neuralNetworks.pdf +604 -0
  47. data/site/build/site/en/skin/CommonMessages_de.xml +23 -0
  48. data/site/build/site/en/skin/CommonMessages_en_US.xml +23 -0
  49. data/site/build/site/en/skin/CommonMessages_es.xml +23 -0
  50. data/site/build/site/en/skin/CommonMessages_fr.xml +23 -0
  51. data/site/build/site/en/skin/basic.css +166 -0
  52. data/site/build/site/en/skin/breadcrumbs-optimized.js +90 -0
  53. data/site/build/site/en/skin/breadcrumbs.js +237 -0
  54. data/site/build/site/en/skin/fontsize.js +166 -0
  55. data/site/build/site/en/skin/getBlank.js +40 -0
  56. data/site/build/site/en/skin/getMenu.js +45 -0
  57. data/site/build/site/en/skin/images/README.txt +1 -0
  58. data/site/build/site/en/skin/images/add.jpg +0 -0
  59. data/site/build/site/en/skin/images/built-with-forrest-button.png +0 -0
  60. data/site/build/site/en/skin/images/chapter.gif +0 -0
  61. data/site/build/site/en/skin/images/chapter_open.gif +0 -0
  62. data/site/build/site/en/skin/images/current.gif +0 -0
  63. data/site/build/site/en/skin/images/error.png +0 -0
  64. data/site/build/site/en/skin/images/external-link.gif +0 -0
  65. data/site/build/site/en/skin/images/fix.jpg +0 -0
  66. data/site/build/site/en/skin/images/forrest-credit-logo.png +0 -0
  67. data/site/build/site/en/skin/images/hack.jpg +0 -0
  68. data/site/build/site/en/skin/images/header_white_line.gif +0 -0
  69. data/site/build/site/en/skin/images/info.png +0 -0
  70. data/site/build/site/en/skin/images/instruction_arrow.png +0 -0
  71. data/site/build/site/en/skin/images/label.gif +0 -0
  72. data/site/build/site/en/skin/images/page.gif +0 -0
  73. data/site/build/site/en/skin/images/pdfdoc.gif +0 -0
  74. data/site/build/site/en/skin/images/poddoc.png +0 -0
  75. data/site/build/site/en/skin/images/printer.gif +0 -0
  76. data/site/build/site/en/skin/images/rc-b-l-15-1body-2menu-3menu.png +0 -0
  77. data/site/build/site/en/skin/images/rc-b-r-15-1body-2menu-3menu.png +0 -0
  78. data/site/build/site/en/skin/images/rc-b-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  79. data/site/build/site/en/skin/images/rc-t-l-5-1header-2searchbox-3searchbox.png +0 -0
  80. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-selected-3tab-selected.png +0 -0
  81. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  82. data/site/build/site/en/skin/images/rc-t-r-15-1body-2menu-3menu.png +0 -0
  83. data/site/build/site/en/skin/images/rc-t-r-5-1header-2searchbox-3searchbox.png +0 -0
  84. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  85. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  86. data/site/build/site/en/skin/images/remove.jpg +0 -0
  87. data/site/build/site/en/skin/images/rss.png +0 -0
  88. data/site/build/site/en/skin/images/spacer.gif +0 -0
  89. data/site/build/site/en/skin/images/success.png +0 -0
  90. data/site/build/site/en/skin/images/txtdoc.png +0 -0
  91. data/site/build/site/en/skin/images/update.jpg +0 -0
  92. data/site/build/site/en/skin/images/valid-html401.png +0 -0
  93. data/site/build/site/en/skin/images/vcss.png +0 -0
  94. data/site/build/site/en/skin/images/warning.png +0 -0
  95. data/site/build/site/en/skin/images/xmldoc.gif +0 -0
  96. data/site/build/site/en/skin/menu.js +48 -0
  97. data/site/build/site/en/skin/note.txt +50 -0
  98. data/site/build/site/en/skin/print.css +54 -0
  99. data/site/build/site/en/skin/profile.css +163 -0
  100. data/site/build/site/en/skin/prototype.js +1257 -0
  101. data/site/build/site/en/skin/screen.css +587 -0
  102. data/site/build/site/en/svn.html +223 -0
  103. data/site/build/site/en/svn.pdf +239 -0
  104. data/site/build/site/en/wholesite.pdf +1686 -0
  105. data/site/build/tmp/brokenlinks.xml +2 -0
  106. data/site/build/tmp/build-info.xml +5 -0
  107. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.data +0 -0
  108. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.index +0 -0
  109. data/site/build/tmp/input.xmap +32 -0
  110. data/site/build/tmp/internal.xmap +32 -0
  111. data/site/build/tmp/locationmap.xml +29 -0
  112. data/site/build/tmp/output.xmap +38 -0
  113. data/site/build/tmp/pluginlist2fetchbuild.xml +144 -0
  114. data/site/build/tmp/plugins-1.xml +212 -0
  115. data/site/build/tmp/plugins-2.xml +347 -0
  116. data/site/build/tmp/projfilters.properties +41 -0
  117. data/site/build/tmp/resources.xmap +32 -0
  118. data/site/build/webapp/WEB-INF/logs/access.log +0 -0
  119. data/site/build/webapp/WEB-INF/logs/core.log +788 -0
  120. data/site/build/webapp/WEB-INF/logs/debug.log +0 -0
  121. data/site/build/webapp/WEB-INF/logs/error.log +248 -0
  122. data/site/build/webapp/WEB-INF/logs/flow.log +0 -0
  123. data/site/build/webapp/WEB-INF/logs/idgen.log +0 -0
  124. data/site/build/webapp/WEB-INF/logs/linkrewriter.log +0 -0
  125. data/site/build/webapp/WEB-INF/logs/locationmap.log +0 -0
  126. data/site/build/webapp/WEB-INF/logs/sitemap.log +0 -0
  127. data/site/build/webapp/WEB-INF/logs/xmlform.log +0 -0
  128. data/site/forrest.properties +152 -0
  129. data/site/forrest.properties.dispatcher.properties +25 -0
  130. data/site/forrest.properties.xml +29 -0
  131. data/site/src/documentation/README.txt +7 -0
  132. data/site/src/documentation/classes/CatalogManager.properties +62 -0
  133. data/site/src/documentation/content/locationmap.xml +72 -0
  134. data/site/src/documentation/content/xdocs/downloads.html +9 -0
  135. data/site/src/documentation/content/xdocs/geneticAlgorithms.xml +280 -0
  136. data/site/src/documentation/content/xdocs/index.xml +73 -0
  137. data/site/src/documentation/content/xdocs/machineLearning.xml +129 -0
  138. data/site/src/documentation/content/xdocs/neuralNetworks.xml +218 -0
  139. data/site/src/documentation/content/xdocs/site.xml +51 -0
  140. data/site/src/documentation/content/xdocs/svn.xml +31 -0
  141. data/site/src/documentation/content/xdocs/tabs.xml +35 -0
  142. data/site/src/documentation/resources/images/ai4r-logo.png +0 -0
  143. data/site/src/documentation/resources/images/c.png +0 -0
  144. data/site/src/documentation/resources/images/c_wbn.png +0 -0
  145. data/site/src/documentation/resources/images/c_wn.png +0 -0
  146. data/site/src/documentation/resources/images/ellipse-2.svg +30 -0
  147. data/site/src/documentation/resources/images/ero.gif +0 -0
  148. data/site/src/documentation/resources/images/europe2.png +0 -0
  149. data/site/src/documentation/resources/images/europe3.png +0 -0
  150. data/site/src/documentation/resources/images/fitness.png +0 -0
  151. data/site/src/documentation/resources/images/icon-a.png +0 -0
  152. data/site/src/documentation/resources/images/icon-b.png +0 -0
  153. data/site/src/documentation/resources/images/icon.png +0 -0
  154. data/site/src/documentation/resources/images/my_email.png +0 -0
  155. data/site/src/documentation/resources/images/project-logo.png +0 -0
  156. data/site/src/documentation/resources/images/rubyforge.png +0 -0
  157. data/site/src/documentation/resources/images/s.png +0 -0
  158. data/site/src/documentation/resources/images/s_wbn.png +0 -0
  159. data/site/src/documentation/resources/images/s_wn.png +0 -0
  160. data/site/src/documentation/resources/images/sigmoid.png +0 -0
  161. data/site/src/documentation/resources/images/sub-dir/icon-c.png +0 -0
  162. data/site/src/documentation/resources/images/t.png +0 -0
  163. data/site/src/documentation/resources/images/t_wbn.png +0 -0
  164. data/site/src/documentation/resources/images/t_wn.png +0 -0
  165. data/site/src/documentation/resources/schema/catalog.xcat +29 -0
  166. data/site/src/documentation/resources/schema/hello-v10.dtd +51 -0
  167. data/site/src/documentation/resources/schema/symbols-project-v10.ent +26 -0
  168. data/site/src/documentation/resources/stylesheets/hello2document.xsl +33 -0
  169. data/site/src/documentation/sitemap.xmap +66 -0
  170. data/site/src/documentation/skinconf.xml +418 -0
  171. data/site/src/documentation/translations/langcode.xml +29 -0
  172. data/site/src/documentation/translations/languages_de.xml +24 -0
  173. data/site/src/documentation/translations/languages_en.xml +24 -0
  174. data/site/src/documentation/translations/languages_es.xml +22 -0
  175. data/site/src/documentation/translations/languages_fr.xml +24 -0
  176. data/site/src/documentation/translations/languages_nl.xml +24 -0
  177. data/site/src/documentation/translations/menu.xml +33 -0
  178. data/site/src/documentation/translations/menu_af.xml +33 -0
  179. data/site/src/documentation/translations/menu_de.xml +33 -0
  180. data/site/src/documentation/translations/menu_es.xml +33 -0
  181. data/site/src/documentation/translations/menu_fr.xml +33 -0
  182. data/site/src/documentation/translations/menu_it.xml +33 -0
  183. data/site/src/documentation/translations/menu_nl.xml +33 -0
  184. data/site/src/documentation/translations/menu_no.xml +33 -0
  185. data/site/src/documentation/translations/menu_ru.xml +33 -0
  186. data/site/src/documentation/translations/menu_sk.xml +33 -0
  187. data/site/src/documentation/translations/tabs.xml +22 -0
  188. data/site/src/documentation/translations/tabs_de.xml +22 -0
  189. data/site/src/documentation/translations/tabs_es.xml +22 -0
  190. data/site/src/documentation/translations/tabs_fr.xml +22 -0
  191. data/site/src/documentation/translations/tabs_nl.xml +22 -0
  192. data/test/decision_tree/id3_test.rb +209 -0
  193. data/test/genetic_algorithm/chromosome_test.rb +55 -0
  194. data/test/genetic_algorithm/genetic_algorithm_test.rb +78 -0
  195. data/test/neural_network/backpropagation_test.rb +44 -0
  196. metadata +274 -0
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = Introduction
2
+
3
+ This project aims to produce ruby implementations of
4
+ algorithms covering several Artificial intelligence fields, including:
5
+
6
+ * Machine Learning (DecisionTree::ID3)
7
+
8
+ Decision Trees using an implementation of ID3 algorithm.
9
+
10
+ * Genetic algorithms (GeneticAlgorithm::GeneticSearch)
11
+
12
+ Implementation of GeneticSearch and Chromosome classes. The GeneticSearch is a generic class, and can be used to solved any kind of problems. The GeneticSearch class performs a stochastic search of the solution of a given problem.
13
+
14
+ * Neural network (NeuralNetwork::Backpropagation)
15
+
16
+ Implementation of neural networks using the Backpropagation supervised learning technique.
17
+
18
+ * Bayesian networks
19
+
20
+ TODO
21
+
22
+ = Where can I find the lastest code and info on this project?
23
+
24
+ http://ai4r.rubyforge.org
25
+
26
+ = How to install
27
+
28
+ 1. Install the gem:
29
+
30
+ gem install http://rubyforge.org/frs/download.php/32923/ai4r-1.0.gem
31
+
32
+ 2. Include require statements in your code:
33
+
34
+ require "rubygems"
35
+ require "decision_tree/id3"
36
+ require "neural_network/backpropagation"
37
+ require "genetic_algorithm/genetic_algorithm"
38
+
39
+ = Feedback
40
+
41
+ If you have some constructive comments about this project, please do send those
42
+ to me: Sergio Fierens (sergio(dot)fierens(at)gmail(dot)com)
43
+
44
+ = Warranty
45
+
46
+ This software is provided "as is" and without any express or implied warranties,
47
+ including, without limitation, the implied warranties of merchantibility and
48
+ fitness for a particular purpose.
@@ -0,0 +1,121 @@
1
+ zone,rooms,size,price
2
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
3
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
4
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
5
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
6
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
7
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
8
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
9
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[36K-45K]
10
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[36K-45K]
11
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[36K-45K]
12
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[29K-35K]
13
+ Moron Sur (GBA),2,[28 m2 - 39 m2],[36K-45K]
14
+ Moron Sur (GBA),2,[40 m2 - 50 m2],[36K-45K]
15
+ Moron Sur (GBA),2,[40 m2 - 50 m2],[29K-35K]
16
+ Moron Sur (GBA),2,[40 m2 - 50 m2],[29K-35K]
17
+ Moron Sur (GBA),2,[40 m2 - 50 m2],[56K-75K]
18
+ Moron Sur (GBA),3,[40 m2 - 50 m2],[36K-45K]
19
+ Moron Sur (GBA),2,[40 m2 - 50 m2],[29K-35K]
20
+ Moron Sur (GBA),2,[51 m2 - 59 m2],[36K-45K]
21
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[46K-55K]
22
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[36K-45K]
23
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[36K-45K]
24
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[36K-45K]
25
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[36K-45K]
26
+ Moron Sur (GBA),3,[51 m2 - 59 m2],[46K-55K]
27
+ Moron Sur (GBA),2,[51 m2 - 59 m2],[46K-55K]
28
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[46K-55K]
29
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[46K-55K]
30
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[56K-75K]
31
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[56K-75K]
32
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[36K-45K]
33
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[36K-45K]
34
+ Moron Sur (GBA),3,[60 m2 - 70 m2],[56K-75K]
35
+ Moron Sur (GBA),3,[71 m2 - 85 m2],[46K-55K]
36
+ Moron Sur (GBA),3,[86 m2 - 100 m2],[46K-55K]
37
+ Moron Sur (GBA),4,[101 m2 - 125 m2],[101K-125K]
38
+ Moron Sur (GBA),3,[101 m2 - 125 m2],[76K-100K]
39
+ Moron Sur (GBA),4,[101 m2 - 125 m2],[170K-200K]
40
+ Moron Sur (GBA),4,[101 m2 - 125 m2],[76K-100K]
41
+ Moron Sur (GBA),4,[126 m2 - 160 m2],[56K-75K]
42
+ Moron Sur (GBA),4,[126 m2 - 160 m2],[126K-150K]
43
+ Recoleta (CABA),2,[28 m2 - 39 m2],[46K-55K]
44
+ Recoleta (CABA),2,[28 m2 - 39 m2],[56K-75K]
45
+ Recoleta (CABA),2,[28 m2 - 39 m2],[56K-75K]
46
+ Recoleta (CABA),2,[28 m2 - 39 m2],[46K-55K]
47
+ Recoleta (CABA),2,[40 m2 - 50 m2],[56K-75K]
48
+ Recoleta (CABA),2,[40 m2 - 50 m2],[76K-100K]
49
+ Recoleta (CABA),2,[40 m2 - 50 m2],[76K-100K]
50
+ Recoleta (CABA),2,[40 m2 - 50 m2],[56K-75K]
51
+ Recoleta (CABA),2,[40 m2 - 50 m2],[101K-125K]
52
+ Recoleta (CABA),2,[51 m2 - 59 m2],[101K-125K]
53
+ Recoleta (CABA),2,[51 m2 - 59 m2],[56K-75K]
54
+ Recoleta (CABA),2,[51 m2 - 59 m2],[76K-100K]
55
+ Recoleta (CABA),2,[51 m2 - 59 m2],[76K-100K]
56
+ Recoleta (CABA),2,[60 m2 - 70 m2],[56K-75K]
57
+ Recoleta (CABA),2,[60 m2 - 70 m2],[76K-100K]
58
+ Recoleta (CABA),3,[60 m2 - 70 m2],[101K-125K]
59
+ Recoleta (CABA),2,[60 m2 - 70 m2],[76K-100K]
60
+ Recoleta (CABA),2,[60 m2 - 70 m2],[76K-100K]
61
+ Recoleta (CABA),2,[60 m2 - 70 m2],[126K-150K]
62
+ Recoleta (CABA),3,[60 m2 - 70 m2],[76K-100K]
63
+ Recoleta (CABA),3,[60 m2 - 70 m2],[76K-100K]
64
+ Recoleta (CABA),2,[71 m2 - 85 m2],[152K-169K]
65
+ Recoleta (CABA),3,[71 m2 - 85 m2],[126K-150K]
66
+ Recoleta (CABA),3,[71 m2 - 85 m2],[152K-169K]
67
+ Recoleta (CABA),3,[71 m2 - 85 m2],[170K-200K]
68
+ Recoleta (CABA),3,[71 m2 - 85 m2],[101K-125K]
69
+ Recoleta (CABA),3,[71 m2 - 85 m2],[170K-200K]
70
+ Recoleta (CABA),3,[71 m2 - 85 m2],[76K-100K]
71
+ Recoleta (CABA),2,[71 m2 - 85 m2],[126K-150K]
72
+ Recoleta (CABA),3,[71 m2 - 85 m2],[126K-150K]
73
+ Recoleta (CABA),2,[71 m2 - 85 m2],[200K-275K]
74
+ Recoleta (CABA),3,[86 m2 - 100 m2],[152K-169K]
75
+ Recoleta (CABA),3,[86 m2 - 100 m2],[170K-200K]
76
+ Recoleta (CABA),4,[86 m2 - 100 m2],[126K-150K]
77
+ Recoleta (CABA),4,[86 m2 - 100 m2],[126K-150K]
78
+ Recoleta (CABA),3,[86 m2 - 100 m2],[200K-275K]
79
+ Recoleta (CABA),3,[86 m2 - 100 m2],[126K-150K]
80
+ Recoleta (CABA),3,[86 m2 - 100 m2],[152K-169K]
81
+ Recoleta (CABA),3,[86 m2 - 100 m2],[200K-275K]
82
+ Recoleta (CABA),3,[101 m2 - 125 m2],[200K-275K]
83
+ Recoleta (CABA),3,[101 m2 - 125 m2],[170K-200K]
84
+ Recoleta (CABA),4,[101 m2 - 125 m2],[170K-200K]
85
+ Recoleta (CABA),4,[101 m2 - 125 m2],[200K-275K]
86
+ Recoleta (CABA),3,[101 m2 - 125 m2],[56K-75K]
87
+ Recoleta (CABA),4,[101 m2 - 125 m2],[200K-275K]
88
+ Recoleta (CABA),4,[101 m2 - 125 m2],[170K-200K]
89
+ Recoleta (CABA),3,[126 m2 - 160 m2],[200K-275K]
90
+ Recoleta (CABA),4,[126 m2 - 160 m2],[200K-275K]
91
+ Recoleta (CABA),3,[126 m2 - 160 m2],[152K-169K]
92
+ Recoleta (CABA),3,[126 m2 - 160 m2],[200K-275K]
93
+ Recoleta (CABA),4,[126 m2 - 160 m2],>275K
94
+ Recoleta (CABA),3,[126 m2 - 160 m2],[200K-275K]
95
+ Recoleta (CABA),4,[126 m2 - 160 m2],>275K
96
+ Recoleta (CABA),3,[126 m2 - 160 m2],[170K-200K]
97
+ Tigre (GBA),2,[28 m2 - 39 m2],[56K-75K]
98
+ Tigre (GBA),2,[40 m2 - 50 m2],[56K-75K]
99
+ Tigre (GBA),2,[40 m2 - 50 m2],[76K-100K]
100
+ Tigre (GBA),2,[51 m2 - 59 m2],[101K-125K]
101
+ Tigre (GBA),2,[51 m2 - 59 m2],[101K-125K]
102
+ Tigre (GBA),3,[51 m2 - 59 m2],[101K-125K]
103
+ Tigre (GBA),3,[51 m2 - 59 m2],[101K-125K]
104
+ Tigre (GBA),3,[51 m2 - 59 m2],[126K-150K]
105
+ Tigre (GBA),2,[71 m2 - 85 m2],[126K-150K]
106
+ Tigre (GBA),2,[71 m2 - 85 m2],[126K-150K]
107
+ Tigre (GBA),2,[71 m2 - 85 m2],[126K-150K]
108
+ Tigre (GBA),3,[86 m2 - 100 m2],[170K-200K]
109
+ Tigre (GBA),4,[86 m2 - 100 m2],[152K-169K]
110
+ Tigre (GBA),4,[86 m2 - 100 m2],[152K-169K]
111
+ Tigre (GBA),3,[86 m2 - 100 m2],[152K-169K]
112
+ Tigre (GBA),3,[86 m2 - 100 m2],[152K-169K]
113
+ Tigre (GBA),3,[101 m2 - 125 m2],[152K-169K]
114
+ Tigre (GBA),4,[101 m2 - 125 m2],[170K-200K]
115
+ Tigre (GBA),4,[101 m2 - 125 m2],[170K-200K]
116
+ Tigre (GBA),4,[101 m2 - 125 m2],[200K-275K]
117
+ Tigre (GBA),4,[101 m2 - 125 m2],[200K-275K]
118
+ Tigre (GBA),4,[101 m2 - 125 m2],[170K-200K]
119
+ Tigre (GBA),4,[101 m2 - 125 m2],>275K
120
+ Tigre (GBA),4,[101 m2 - 125 m2],>275K
121
+ Tigre (GBA),4,[126 m2 - 160 m2],>275K
@@ -0,0 +1,31 @@
1
+ # Author:: Sergio Fierens
2
+ # License:: MPL 1.1
3
+ # Project:: ai4r
4
+ # Url:: http://ai4r.rubyforge.org/
5
+ #
6
+ # You can redistribute it and/or modify it under the terms of
7
+ # the Mozilla Public License version 1.1 as published by the
8
+ # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
9
+
10
+ require File.dirname(__FILE__) + '/../../lib/decision_tree/id3'
11
+ require 'csv'
12
+
13
+ # Load data from data_set.csv
14
+ data_set = []
15
+ CSV::Reader.parse(File.open("#{File.dirname(__FILE__)}/data_set.csv", 'r')) do |row|
16
+ data_set << row
17
+ end
18
+ data_labels = data_set.shift
19
+
20
+ # Build ID3 tree
21
+ id3 = DecisionTree::ID3.new(data_set, data_labels)
22
+
23
+ # Show rules
24
+ puts "Discovered rules are:"
25
+ puts id3.to_s
26
+
27
+ # Try to predict some values
28
+ puts "['Moron Sur (GBA)','4','[86 m2 - 100 m2]'] => " + id3.eval(['Moron Sur (GBA)','4','[86 m2 - 100 m2]'])
29
+ puts "['Moron Sur (GBA)','3','[101 m2 - 125 m2]'] => " + id3.eval(['Moron Sur (GBA)','3','[101 m2 - 125 m2]'])
30
+ puts "['Recoleta (CABA)','3','[86 m2 - 100 m2]'] => " + id3.eval(['Recoleta (CABA)','3','[86 m2 - 100 m2]',])
31
+ puts "['Tigre (GBA)','3','[71 m2 - 85 m2]'] => " + id3.eval(['Tigre (GBA)','3','[71 m2 - 85 m2]',])
@@ -0,0 +1,29 @@
1
+ Discovered rules are:
2
+ if size=='[28 m2 - 39 m2]' and zone=='Moron Sur (GBA)' then price='[29K-35K]'
3
+ elsif size=='[28 m2 - 39 m2]' and zone=='Recoleta (CABA)' then price='[46K-55K]'
4
+ elsif size=='[28 m2 - 39 m2]' and zone=='Tigre (GBA)' then price='[56K-75K]'
5
+ elsif size=='[40 m2 - 50 m2]' and zone=='Moron Sur (GBA)' then price='[29K-35K]'
6
+ elsif size=='[40 m2 - 50 m2]' and zone=='Recoleta (CABA)' then price='[56K-75K]'
7
+ elsif size=='[40 m2 - 50 m2]' and zone=='Tigre (GBA)' then price='[56K-75K]'
8
+ elsif size=='[51 m2 - 59 m2]' and zone=='Moron Sur (GBA)' then price='[36K-45K]'
9
+ elsif size=='[51 m2 - 59 m2]' and zone=='Recoleta (CABA)' then price='[76K-100K]'
10
+ elsif size=='[51 m2 - 59 m2]' and zone=='Tigre (GBA)' then price='[101K-125K]'
11
+ elsif size=='[60 m2 - 70 m2]' and zone=='Moron Sur (GBA)' then price='[56K-75K]'
12
+ elsif size=='[60 m2 - 70 m2]' and zone=='Recoleta (CABA)' then price='[76K-100K]'
13
+ elsif size=='[71 m2 - 85 m2]' and zone=='Moron Sur (GBA)' then price='[46K-55K]'
14
+ elsif size=='[71 m2 - 85 m2]' and zone=='Recoleta (CABA)' then price='[126K-150K]'
15
+ elsif size=='[71 m2 - 85 m2]' and zone=='Tigre (GBA)' then price='[126K-150K]'
16
+ elsif size=='[86 m2 - 100 m2]' and zone=='Moron Sur (GBA)' then price='[46K-55K]'
17
+ elsif size=='[86 m2 - 100 m2]' and zone=='Recoleta (CABA)' then price='[126K-150K]'
18
+ elsif size=='[86 m2 - 100 m2]' and zone=='Tigre (GBA)' then price='[152K-169K]'
19
+ elsif size=='[101 m2 - 125 m2]' and zone=='Moron Sur (GBA)' then price='[76K-100K]'
20
+ elsif size=='[101 m2 - 125 m2]' and zone=='Recoleta (CABA)' then price='[200K-275K]'
21
+ elsif size=='[101 m2 - 125 m2]' and zone=='Tigre (GBA)' then price='[170K-200K]'
22
+ elsif size=='[126 m2 - 160 m2]' and zone=='Moron Sur (GBA)' then price='[56K-75K]'
23
+ elsif size=='[126 m2 - 160 m2]' and zone=='Recoleta (CABA)' then price='[200K-275K]'
24
+ elsif size=='[126 m2 - 160 m2]' and zone=='Tigre (GBA)' then price='>275K'
25
+ else raise 'There was not enough information during training to do a proper induction for this data element' end
26
+ ['Moron Sur (GBA)','4','[86 m2 - 100 m2]'] => [46K-55K]
27
+ ['Moron Sur (GBA)','3','[101 m2 - 125 m2]'] => [76K-100K]
28
+ ['Recoleta (CABA)','3','[86 m2 - 100 m2]'] => [126K-150K]
29
+ ['Tigre (GBA)','3','[71 m2 - 85 m2]'] => [126K-150K]
@@ -0,0 +1,39 @@
1
+ # Author:: Sergio Fierens
2
+ # License:: MPL 1.1
3
+ # Project:: ai4r
4
+ # Url:: http://ai4r.rubyforge.org/
5
+ #
6
+ # You can redistribute it and/or modify it under the terms of
7
+ # the Mozilla Public License version 1.1 as published by the
8
+ # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
9
+
10
+ require File.dirname(__FILE__) + '/../../lib/genetic_algorithm/genetic_algorithm'
11
+ require 'csv'
12
+
13
+ # Load data from data_set.csv
14
+ data_set = []
15
+ CSV::Reader.parse(File.open("#{File.dirname(__FILE__)}/travel_cost.csv", 'r')) do |row|
16
+ data_set << row
17
+ end
18
+ data_labels = data_set.shift
19
+ data_set.collect! do |column|
20
+ column.collect { |element| element.to_f}
21
+ end
22
+
23
+ GeneticAlgorithm::Chromosome.set_cost_matrix(data_set)
24
+
25
+ puts "Some random selected tours costs: "
26
+ 3.times do
27
+ c = GeneticAlgorithm::Chromosome.seed
28
+ puts "COST #{c.fitness} TOUR: #{c.data.collect{ |c| data_labels[c]} * ', '}"
29
+ end
30
+
31
+ puts "Beginning genetic search, please wait... "
32
+ search = GeneticAlgorithm::GeneticSearch.new(800, 100)
33
+ result = search.run
34
+ puts "BEST COST FOUND #{result.fitness} TOUR: #{result.data.collect{ |c| data_labels[c]} * ', '}"
35
+
36
+ # $7611.99 TOUR: Moscow, Kiev, Warsaw, Hamburg, Berlin, Vienna, Munich, Milan, Rome, Barcelona, Madrid, Paris, Brussels, London, Dublin
37
+ # $7659.81 TOUR: Moscow, Kiev, Warsaw, Vienna, Munich, Berlin, Hamburg, Brussels, Dublin, London, Paris, Milan, Rome, Barcelona, Madrid
38
+ # $7596.74 TOUR: Moscow, Kiev, Warsaw, Berlin, Hamburg, Vienna, Munich, Milan, Rome, Barcelona, Madrid, Paris, Brussels, London Dublin
39
+
@@ -0,0 +1,16 @@
1
+ "Barcelona","Berlin","Brussels","Dublin","Hamburg","Kiev","London","Madrid","Milan","Moscow","Munich","Paris","Rome","Vienna","Warsaw"
2
+ 0,"1497.61","1062.89","1469.29","1471.78","2391.06","1137.67","504.64","725.12","3006.93","1054.55","831.59","856.69","1347.43","1862.33"
3
+ "1497.61",0,"651.62","1315.16","254.51","1204.00","929.97","1867.69","840.72","1607.99","501.97","876.96","1181.67","523.61","516.06"
4
+ "1062.89","651.62",0,"773.20","489.76","1836.20","318.72","1314.30","696.61","2253.26","601.87","261.29","1171.34","914.81","1159.85"
5
+ "1469.29","1315.16","773.20",0,"1073.36","2513.69","462.60","1449.96","1413.37","2792.41","1374.91","776.83","1882.22","1680.00","1823.72"
6
+ "1471.78","254.51","489.76","1073.36",0,"1440.34","720.12","1785.33","900.01","1779.93","610.17","744.63","1307.51","742.79","750.49"
7
+ "2391.06","1204.00","1836.20","2513.69","1440.34",0,"2131.20","2859.32","1672.69","756.61","1391.36","2022.76","1673.74","1052.76","690.12"
8
+ "1137.67","929.97","318.72","462.60","720.12","2131.20",0,"1263.37","957.91","2498.32","916.23","340.55","1431.21","1233.48","1445.85"
9
+ "504.64","1867.69","1314.30","1449.96","1785.33","2859.32","1263.37",0,"1187.73","3437.70","1484.53","1053.40","1360.80","1807.09","2288.42"
10
+ "725.12","840.72","696.61","1413.37","900.01","1672.69","957.91","1187.73",0,"2283.19","348.89","641.31","476.00","623.36","1143.01"
11
+ "3006.93","1607.99","2253.26","2792.41","1779.93","756.61","2498.32","3437.70","2283.19",0,"1957.15","2484.92","2374.26","1669.22","1149.41"
12
+ "1054.55","501.97","601.87","1374.91","610.17","1391.36","916.23","1484.53","348.89","1957.15",0,"685.14","698.04","354.42","809.02"
13
+ "831.59","876.96","261.29","776.83","744.63","2022.76","340.55","1053.40","641.31","2484.92","685.14",0,"1105.76","1033.73","1365.91"
14
+ "856.69","1181.67","1171.34","1882.22","1307.51","1673.74","1431.21","1360.80","476.00","2374.26","698.04","1105.76",0,"763.26","1316.24"
15
+ "1347.43","523.61","914.81","1680.00","742.79","1052.76","1233.48","1807.09","623.36","1669.22","354.42","1033.73","763.26",0,"557.43"
16
+ "1862.33","516.06","1159.85","1823.72","750.49","690.12","1445.85","2288.42","1143.01","1149.41","809.02","1365.91","1316.24","557.43",0
@@ -0,0 +1,65 @@
1
+ # Author:: Sergio Fierens
2
+ # License:: MPL 1.1
3
+ # Project:: ai4r
4
+ # Url:: http://ai4r.rubyforge.org/
5
+ #
6
+ # You can redistribute it and/or modify it under the terms of
7
+ # the Mozilla Public License version 1.1 as published by the
8
+ # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
9
+
10
+ require File.dirname(__FILE__) + '/training_patterns'
11
+ require File.dirname(__FILE__) + '/patterns_with_noise'
12
+ require File.dirname(__FILE__) + '/patterns_with_base_noise'
13
+ require File.dirname(__FILE__) + '/../../lib/neural_network/backpropagation'
14
+ require 'benchmark'
15
+
16
+ times = Benchmark.measure do
17
+
18
+ net = NeuralNetwork::Backpropagation.new([256, 3])
19
+
20
+ tr_input = TRIANGLE.flatten.collect { |input| input.to_f / 10}
21
+ sq_input = SQUARE.flatten.collect { |input| input.to_f / 10}
22
+ cr_input = CROSS.flatten.collect { |input| input.to_f / 10}
23
+
24
+ tr_with_noise = TRIANGLE_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
25
+ sq_with_noise = SQUARE_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
26
+ cr_with_noise = CROSS_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
27
+
28
+ tr_with_base_noise = TRIANGLE_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
29
+ sq_with_base_noise = SQUARE_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
30
+ cr_with_base_noise = CROSS_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
31
+
32
+ puts "Training the network, please wait."
33
+ 200.times do
34
+ net.train(tr_input, [1,0,0])
35
+ net.train(sq_input, [0,1,0])
36
+ net.train(cr_input, [0,0,1])
37
+ end
38
+
39
+ def result_label(result)
40
+ if result[0] > result[1] && result[0] > result[2]
41
+ "TRIANGLE"
42
+ elsif result[1] > result[2]
43
+ "SQUARE"
44
+ else
45
+ "CROSS"
46
+ end
47
+ end
48
+
49
+ puts "Training Examples"
50
+ puts "#{net.eval(tr_input).inspect} => #{result_label(net.eval(tr_input))}"
51
+ puts "#{net.eval(sq_input).inspect} => #{result_label(net.eval(sq_input))}"
52
+ puts "#{net.eval(cr_input).inspect} => #{result_label(net.eval(cr_input))}"
53
+ puts "Examples with noise"
54
+ puts "#{net.eval(tr_with_noise).inspect} => #{result_label(net.eval(tr_with_noise))}"
55
+ puts "#{net.eval(sq_with_noise).inspect} => #{result_label(net.eval(sq_with_noise))}"
56
+ puts "#{net.eval(cr_with_noise).inspect} => #{result_label(net.eval(cr_with_noise))}"
57
+ puts "Examples with base noise"
58
+ puts "#{net.eval(tr_with_base_noise).inspect} => #{result_label(net.eval(tr_with_base_noise))}"
59
+ puts "#{net.eval(sq_with_base_noise).inspect} => #{result_label(net.eval(sq_with_base_noise))}"
60
+ puts "#{net.eval(cr_with_base_noise).inspect} => #{result_label(net.eval(cr_with_base_noise))}"
61
+
62
+
63
+ end
64
+
65
+ puts "Elapsed time: #{times}"
@@ -0,0 +1,68 @@
1
+ # Author:: Sergio Fierens
2
+ # License:: MPL 1.1
3
+ # Project:: ai4r
4
+ # Url:: http://ai4r.rubyforge.org/
5
+ #
6
+ # You can redistribute it and/or modify it under the terms of
7
+ # the Mozilla Public License version 1.1 as published by the
8
+ # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
9
+
10
+
11
+ TRIANGLE_WITH_BASE_NOISE = [
12
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
13
+ [ 3, 3, 3, 3, 3, 3, 4, 10, 10, 4, 3, 3, 3, 3, 3, 3],
14
+ [ 3, 3, 3, 3, 3, 3, 8, 8, 8, 8, 3,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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],
59
+ [ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],
60
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
61
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
62
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
63
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
64
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
65
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3],
66
+ [ 3, 3, 3, 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3]
67
+ ]
68
+
@@ -0,0 +1,66 @@
1
+ # Author:: Sergio Fierens
2
+ # License:: MPL 1.1
3
+ # Project:: ai4r
4
+ # Url:: http://ai4r.rubyforge.org/
5
+ #
6
+ # You can redistribute it and/or modify it under the terms of
7
+ # the Mozilla Public License version 1.1 as published by the
8
+ # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
9
+
10
+ TRIANGLE_WITH_NOISE = [
11
+ [ 1, 0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 1, 0, 0, 0, 0],
12
+ [ 0, 0, 0, 0, 3, 0, 1, 9, 9, 1, 0, 0, 0, 0, 3, 0],
13
+ [ 0, 3, 0, 0, 0, 0, 5, 1, 5, 3, 0, 0, 0, 0, 0, 7],
14
+ [ 0, 0, 0, 7, 0, 1, 9, 1, 1, 9, 1, 0, 0, 0, 3, 0],
15
+ [ 0, 0, 0, 0, 0, 3, 5, 0, 3, 5, 5, 0, 0, 0, 0, 0],
16
+ [ 0, 1, 0, 0, 1, 9, 1, 0, 1, 1, 9, 1,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