ai4r 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/README.rdoc +21 -20
  2. data/examples/decision_trees/id3_example.rb +3 -2
  3. data/examples/genetic_algorithm/genetic_algorithm_example.rb +6 -6
  4. data/examples/neural_network/backpropagation_example.rb +2 -2
  5. data/lib/ai4r/classifiers/classifier_helper.rb +54 -0
  6. data/lib/ai4r/classifiers/id3.rb +356 -0
  7. data/lib/ai4r/classifiers/one_r.rb +148 -0
  8. data/lib/ai4r/classifiers/prism.rb +231 -0
  9. data/lib/ai4r/classifiers/zero_r.rb +104 -0
  10. data/lib/ai4r/genetic_algorithm/genetic_algorithm.rb +272 -0
  11. data/lib/ai4r/neural_network/backpropagation.rb +271 -0
  12. data/site/build/tmp/locationmap.xml +14 -14
  13. data/site/build/tmp/output.xmap +23 -23
  14. data/site/build/tmp/pluginlist2fetchbuild.xml +144 -144
  15. data/site/build/tmp/plugins-1.xml +0 -11
  16. data/site/build/tmp/plugins-2.xml +54 -0
  17. data/site/build/tmp/projfilters.properties +41 -41
  18. data/site/build/webapp/WEB-INF/logs/core.log +681 -788
  19. data/site/build/webapp/WEB-INF/logs/error.log +281 -248
  20. data/site/build/webapp/WEB-INF/logs/sitemap.log +1015 -0
  21. data/site/src/documentation/content/xdocs/forum.html +9 -0
  22. data/site/src/documentation/content/xdocs/geneticAlgorithms.xml +82 -68
  23. data/site/src/documentation/content/xdocs/index.xml +47 -18
  24. data/site/src/documentation/content/xdocs/machineLearning.xml +10 -9
  25. data/site/src/documentation/content/xdocs/neuralNetworks.xml +60 -36
  26. data/site/src/documentation/content/xdocs/site.xml +8 -5
  27. data/site/src/documentation/content/xdocs/svn.xml +11 -1
  28. data/site/src/documentation/resources/images/Thumbs.db +0 -0
  29. data/site/src/documentation/resources/images/ai4r-logo.png +0 -0
  30. data/site/src/documentation/resources/images/genetic_algorithms_example.png +0 -0
  31. data/site/src/documentation/resources/images/jadeferret.png +0 -0
  32. data/site/src/documentation/resources/images/neural_network_example.png +0 -0
  33. data/site/src/documentation/resources/images/sub-dir/Thumbs.db +0 -0
  34. data/site/src/documentation/skinconf.xml +18 -18
  35. data/test/classifiers/id3_test.rb +206 -0
  36. data/test/classifiers/one_r_test.rb +62 -0
  37. data/test/classifiers/prism_test.rb +83 -0
  38. data/test/classifiers/zero_r_test.rb +48 -0
  39. data/test/genetic_algorithm/chromosome_test.rb +41 -38
  40. data/test/genetic_algorithm/genetic_algorithm_test.rb +64 -61
  41. data/test/neural_network/backpropagation_test.rb +20 -18
  42. metadata +109 -199
  43. data/lib/decision_tree/id3.rb +0 -354
  44. data/lib/genetic_algorithm/genetic_algorithm.rb +0 -268
  45. data/lib/neural_network/backpropagation.rb +0 -264
  46. data/site/build/site/en/broken-links.xml +0 -2
  47. data/site/build/site/en/downloads.html +0 -187
  48. data/site/build/site/en/downloads.pdf +0 -151
  49. data/site/build/site/en/geneticAlgorithms.html +0 -564
  50. data/site/build/site/en/geneticAlgorithms.pdf +0 -911
  51. data/site/build/site/en/images/ai4r-logo.png +0 -0
  52. data/site/build/site/en/images/built-with-forrest-button.png +0 -0
  53. data/site/build/site/en/images/c.png +0 -0
  54. data/site/build/site/en/images/c_wbn.png +0 -0
  55. data/site/build/site/en/images/c_wn.png +0 -0
  56. data/site/build/site/en/images/ero.gif +0 -0
  57. data/site/build/site/en/images/europe2.png +0 -0
  58. data/site/build/site/en/images/europe3.png +0 -0
  59. data/site/build/site/en/images/fitness.png +0 -0
  60. data/site/build/site/en/images/instruction_arrow.png +0 -0
  61. data/site/build/site/en/images/my_email.png +0 -0
  62. data/site/build/site/en/images/rubyforge.png +0 -0
  63. data/site/build/site/en/images/s.png +0 -0
  64. data/site/build/site/en/images/s_wbn.png +0 -0
  65. data/site/build/site/en/images/s_wn.png +0 -0
  66. data/site/build/site/en/images/sigmoid.png +0 -0
  67. data/site/build/site/en/images/t.png +0 -0
  68. data/site/build/site/en/images/t_wbn.png +0 -0
  69. data/site/build/site/en/images/t_wn.png +0 -0
  70. data/site/build/site/en/index.html +0 -258
  71. data/site/build/site/en/index.pdf +0 -306
  72. data/site/build/site/en/linkmap.html +0 -231
  73. data/site/build/site/en/linkmap.pdf +0 -94
  74. data/site/build/site/en/locationmap.xml +0 -72
  75. data/site/build/site/en/machineLearning.html +0 -325
  76. data/site/build/site/en/machineLearning.pdf +0 -337
  77. data/site/build/site/en/neuralNetworks.html +0 -446
  78. data/site/build/site/en/neuralNetworks.pdf +0 -604
  79. data/site/build/site/en/skin/CommonMessages_de.xml +0 -23
  80. data/site/build/site/en/skin/CommonMessages_en_US.xml +0 -23
  81. data/site/build/site/en/skin/CommonMessages_es.xml +0 -23
  82. data/site/build/site/en/skin/CommonMessages_fr.xml +0 -23
  83. data/site/build/site/en/skin/basic.css +0 -166
  84. data/site/build/site/en/skin/breadcrumbs-optimized.js +0 -90
  85. data/site/build/site/en/skin/breadcrumbs.js +0 -237
  86. data/site/build/site/en/skin/fontsize.js +0 -166
  87. data/site/build/site/en/skin/getBlank.js +0 -40
  88. data/site/build/site/en/skin/getMenu.js +0 -45
  89. data/site/build/site/en/skin/images/README.txt +0 -1
  90. data/site/build/site/en/skin/images/add.jpg +0 -0
  91. data/site/build/site/en/skin/images/built-with-forrest-button.png +0 -0
  92. data/site/build/site/en/skin/images/chapter.gif +0 -0
  93. data/site/build/site/en/skin/images/chapter_open.gif +0 -0
  94. data/site/build/site/en/skin/images/current.gif +0 -0
  95. data/site/build/site/en/skin/images/error.png +0 -0
  96. data/site/build/site/en/skin/images/external-link.gif +0 -0
  97. data/site/build/site/en/skin/images/fix.jpg +0 -0
  98. data/site/build/site/en/skin/images/forrest-credit-logo.png +0 -0
  99. data/site/build/site/en/skin/images/hack.jpg +0 -0
  100. data/site/build/site/en/skin/images/header_white_line.gif +0 -0
  101. data/site/build/site/en/skin/images/info.png +0 -0
  102. data/site/build/site/en/skin/images/instruction_arrow.png +0 -0
  103. data/site/build/site/en/skin/images/label.gif +0 -0
  104. data/site/build/site/en/skin/images/page.gif +0 -0
  105. data/site/build/site/en/skin/images/pdfdoc.gif +0 -0
  106. data/site/build/site/en/skin/images/poddoc.png +0 -0
  107. data/site/build/site/en/skin/images/printer.gif +0 -0
  108. data/site/build/site/en/skin/images/rc-b-l-15-1body-2menu-3menu.png +0 -0
  109. data/site/build/site/en/skin/images/rc-b-r-15-1body-2menu-3menu.png +0 -0
  110. data/site/build/site/en/skin/images/rc-b-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  111. data/site/build/site/en/skin/images/rc-t-l-5-1header-2searchbox-3searchbox.png +0 -0
  112. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-selected-3tab-selected.png +0 -0
  113. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  114. data/site/build/site/en/skin/images/rc-t-r-15-1body-2menu-3menu.png +0 -0
  115. data/site/build/site/en/skin/images/rc-t-r-5-1header-2searchbox-3searchbox.png +0 -0
  116. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  117. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  118. data/site/build/site/en/skin/images/remove.jpg +0 -0
  119. data/site/build/site/en/skin/images/rss.png +0 -0
  120. data/site/build/site/en/skin/images/spacer.gif +0 -0
  121. data/site/build/site/en/skin/images/success.png +0 -0
  122. data/site/build/site/en/skin/images/txtdoc.png +0 -0
  123. data/site/build/site/en/skin/images/update.jpg +0 -0
  124. data/site/build/site/en/skin/images/valid-html401.png +0 -0
  125. data/site/build/site/en/skin/images/vcss.png +0 -0
  126. data/site/build/site/en/skin/images/warning.png +0 -0
  127. data/site/build/site/en/skin/images/xmldoc.gif +0 -0
  128. data/site/build/site/en/skin/menu.js +0 -48
  129. data/site/build/site/en/skin/note.txt +0 -50
  130. data/site/build/site/en/skin/print.css +0 -54
  131. data/site/build/site/en/skin/profile.css +0 -163
  132. data/site/build/site/en/skin/prototype.js +0 -1257
  133. data/site/build/site/en/skin/screen.css +0 -587
  134. data/site/build/site/en/svn.html +0 -223
  135. data/site/build/site/en/svn.pdf +0 -239
  136. data/site/build/site/en/wholesite.pdf +0 -1686
  137. data/site/build/tmp/brokenlinks.xml +0 -2
  138. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.data +0 -0
  139. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.index +0 -0
  140. data/test/decision_tree/id3_test.rb +0 -209
@@ -1,337 +0,0 @@
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 652 /Filter [ /ASCII85Decode /FlateDecode ]
9
- >>
10
- stream
11
- GauI44d4VC&;GQ1$;.o9#O&c^kMhoQ`'k;]8IB9BR>D=^6C7K)7j$BA/pF(dE9+mKYUo.9?1"Wtma`Oj&LOI/#GhCS"U%g+7ATfXPkT5j6u\N(W&UM)M[ePaU_6>mL8A%^\G.2V;,UCJo2F?FW5jZ)`.Q^a7V]>!hb`kBfeG=:@gXGK"8emGnY^PWG5LaZ.AH8('45aD@2^K<(Z3f]L#[VrU%^7tBk<"(c.-0[.%0q,K_5g:85VGEUV8U4Aj'u)XWNfc\nlS6#lAYHeM)0"7`"C_Rh"@rM$ArXpiNE38o`KJ$!OQY$7*I3`PpsgGh*gO^'j8T`$+'9&f,S!%C`&m_i4B0O!jtX[EZY-"<=5gA`fFKUQjW`Qp^Iq],b&N%tLCU92QLG3"*g:?3tD$JK'p1E_s1+jUh:5F5eJK1iWrN1oQ`Q,WX.T:shB,ch\^BXgB^o9T^\6Hi5E?n\jaZO+m:7MJ&^t7XrB'VDrRX`q*Ftl]!f/%IgK;m;!dSj\[Q.-jVmM`6HX;WKLbHjRVm!'u>s)W=3-G8lD2!?$s=.R)R,PZk#>)X1fIV.m/D>Q:A.2MeLtZ7X9f"#Ni-PSW0]\(7N-B(/n%gO;-2W@4J6BYGEp>H!TRHY!EJV]gX.a@@flD+fsS_FH21~>
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
- /Annots 7 0 R
21
- >>
22
- endobj
23
- 7 0 obj
24
- [
25
- 8 0 R
26
- 10 0 R
27
- 12 0 R
28
- 14 0 R
29
- 16 0 R
30
- ]
31
- endobj
32
- 8 0 obj
33
- << /Type /Annot
34
- /Subtype /Link
35
- /Rect [ 102.0 532.666 252.992 520.666 ]
36
- /C [ 0 0 0 ]
37
- /Border [ 0 0 0 ]
38
- /A 9 0 R
39
- /H /I
40
- >>
41
- endobj
42
- 10 0 obj
43
- << /Type /Annot
44
- /Subtype /Link
45
- /Rect [ 102.0 514.466 442.28 502.466 ]
46
- /C [ 0 0 0 ]
47
- /Border [ 0 0 0 ]
48
- /A 11 0 R
49
- /H /I
50
- >>
51
- endobj
52
- 12 0 obj
53
- << /Type /Annot
54
- /Subtype /Link
55
- /Rect [ 102.0 496.266 201.32 484.266 ]
56
- /C [ 0 0 0 ]
57
- /Border [ 0 0 0 ]
58
- /A 13 0 R
59
- /H /I
60
- >>
61
- endobj
62
- 14 0 obj
63
- << /Type /Annot
64
- /Subtype /Link
65
- /Rect [ 102.0 478.066 254.312 466.066 ]
66
- /C [ 0 0 0 ]
67
- /Border [ 0 0 0 ]
68
- /A 15 0 R
69
- /H /I
70
- >>
71
- endobj
72
- 16 0 obj
73
- << /Type /Annot
74
- /Subtype /Link
75
- /Rect [ 102.0 459.866 276.296 447.866 ]
76
- /C [ 0 0 0 ]
77
- /Border [ 0 0 0 ]
78
- /A 17 0 R
79
- /H /I
80
- >>
81
- endobj
82
- 18 0 obj
83
- << /Length 1823 /Filter [ /ASCII85Decode /FlateDecode ]
84
- >>
85
- stream
86
- GauHL>Ar7S'Roe[&GkAj86D%d(YaK4M@OL.[baB6"9iYi10[n'.4JU&rJi-r3csH86dXM:9iC&_Icj&2Qq^o5-9ilBpb$raZlcuP`0=(Gn3-R>r-Eb,I)9.71")Ic5##A--I:P%%]_P4Q4jU\R7#rVSG&oE_Y1d5XduMjN1;mE]HQn=?!\G?</XZ=HrqsXg@<<+-6c*j;<;P@k1hr&5?i\A_lXU#ogfc"]pLW#[ZnMDGUoUB+_S_$>6/@e<=D"[=<Jd;HBZIYbY)@PYEqeBPru3@[rhT@;l0%YjO\%c6>tDV7+B10/7^cdF^sJV'1JU\8gZVmfuenHpeFufO/NdBcB2^pm^uG#;N10"p#[IG>ATK#Sh%'NM-R!rG-mAE0qKmme.VNI]*"p0q,3^TT&EVAYbCVbec",JZr=XBhZiUQ92SYXP0noU9;3IM8=!6@"H08M'M1%2<G=Tb[`kO$\[?i;b8$n/GF'h2.'9MWaS0CW5G@UJAf3qbhg))J+9aThetA4A<;h?1@&JH&(TUg>X<cqHOj#=i7#'j0ghQE_K?Q5BK3'nKJX4FuW0N1OWA$(C3^M*#&6-`$#_(*SU!*jcU];OYHm+Dfa*V6e)8>D$J<1KmB^:DZRCj8;Aa-K47Y'6i5pn@dN>,Npei6>=(2,Y$-nX9gjV0SD3bjj%Jf;3"HW?:Gp[Kqh1tuRQRj6Lm!Th.*\C22P].nW'@7#fW6U2<Tkms(,+"E>,ZMm51aju*U,bVeMKVK[c+Nt@!>/=>KPN%g2PVjphjGI4q`Mg!h=;BcE]kfZ\CflYnmW4$U"#\DWSE@Dqe(tN86DIJ:Sej*oG@gT`/>n;N;/J5F#.:\+LE()K!('g=XW3-?Yh<Q%Z'Vt;b%hB8.Y6MW98n(o/K<_DB4M2YQBu*Con&!QS[.QKm_r%Zd$a24J]#Y13m[5udmbh9"/]:Z>=8k2J"a2B5#=tc_Yr8I&;Llni<0*doC&'r)-d+<f%H`%14)-VLU2NLgd4g'0P[A<d2GcOlb_4Yn@Z?&?%.-Mq;V)E0-Fai)]=,IL0)93\kqMEoGfH=<.6VI:SkH+M*I-B>3c([X``50Sh](c]\2oQ:.U1f:9fmf?I'*QBV5$OqE4G,lg;u)9g?efE8iCtZpq]'K^!D-D&1o%i",PQYLB!4;)W;#)(b(+]NdaeUq/]/4dpWVOb!I%ibqR<*dT(?I_C:6O2U\BZgj_RoH#p@PtNcXH@9Ch4ILg,eL<OZO`=]S^A3#8QOB);LuV:jE*+(I6fn9=["5e0cm.9>oHL"g&%^mW"6u*>jB*L8FfI&6C3F\[$6GrWO5TaL#Tgr-$j\p8"-52VoJZ+L#lG8Tc"-^Y]t-/`^qo?LhebC+4)l&h6nC<@03CIENSAOPlps3??]N2(l3**KHZ>cRM40RqH9P#g\=\<njKX+8kF=qVkW33-hFVPdX.eGH:aPOC1%*7_pVbCMK;D*k\(?$/7m-lf4Kd"jH&Vt^M8N`^)Lp!1>EtliXf+itGBjRYiU1XAgQloPQjVQT-fZh5CERN'o-T2QYDQ5J@gM$P"S_cQk32d;[uR)bdi:Dq29/G`iI:R,0O\8j(@P\K@M7DN-$SWUFN@=^c\Mi%.V(/?4DlJE+;QJm2\LmSm6^6VNFd?adP#e<s*eAmAc3T1\mOg-?N#be2sanel;sLXIP`=D^JbZei7H+'46>,/E]to57]lj\?52gLq[;+bM](tlbki6O,iYN\UGo5)NoA^T5]=\&CFQsHRldCn<HHn#UY:^Zgh4M5]G(j^0@HXg&+__P)VMhnC)8L,bdWdj0R@DC+jI,_ckZLdj]Msn~>
87
- endstream
88
- endobj
89
- 19 0 obj
90
- << /Type /Page
91
- /Parent 1 0 R
92
- /MediaBox [ 0 0 612 792 ]
93
- /Resources 3 0 R
94
- /Contents 18 0 R
95
- >>
96
- endobj
97
- 20 0 obj
98
- << /Length 1771 /Filter [ /ASCII85Decode /FlateDecode ]
99
- >>
100
- stream
101
- Gau0DD,8nW&H9tYnBhaQ&o>67IRBqE:oHA$lE3N&<<P``]Lf1OG&G!E6eD5(2g0$+)!i$@]guPWGWkNebcX`24(k=Z5Bj%^LVNRFO\8s"pO2fi]]/p@nrUAudE9#Uq0hG%>44L)@4qK9.a"fek=uijdsL7<;I?%d%P8`]Ag!p(#%T\-GcZ/A$V<USdE9!@-8?kpS)eqANALF]/u54D-pePmgP)j)S-.Y#A.F[W_EDI7,+7*hEip`mVK6m%1jHpoJULuC.^dbul7^:*l$Qs9Sh"k=pcNe;5j=[IN^_@H!4C&JFBrt^^iRPC8>/^e92$#j!6\+Ra]-Ql-YBb#DkkK"6MX[No8TRY@DU8Fp7o4.][*#Fnf5!lL^;^Ip;_'W]dP(rpO0A2pE4Qr?BEW"I:5PAn)s=[p_2r5$R-5S7[LD)ZqN/6(bLtAoY&I#O_2TG.a9mCKr'uTQKaYk8VRY42]Abbk(C7Pc,mO0kkPgIWY11F'Gu2/f%F5@X?YQ8gY0Id*4Z3_&kdjfWMNdte-rR*n`)m#OPrJbR:d[1h9"c'Ghl5nq^ABH#%7;Fi+BXRM):fC$'2f[1cEH[cm0Zf+.uhd<roHo4VIQ"2L<`lD/9WN;C>j^48>sK>^3M1JeQMT8eJrSAP=!4MQVP5;9MYQASS>]/c6EI:I8[\i>aK&*7(=[_]08/,-'A18?G'h"\WMTQcPD%L7UP=)b\s69=/Z%/*qek`%'69cVmf^'hA3K=6l^*pTYpKkS#>'dE1dqW#S8#1e[Ec0&lc8+%-*?=6"7Cf?t,rp#`(6Y"!,_m=ds*3+SpgIop/BS7\f:P*;rSeC#HUT^F`g0<2PEb`\eHXhoJ]1`&>#_U_6l'#/(J\(af"%fj?ofcgQ_>Tp10ZFAFESUE)W#N/qqJ63d4ISpfA6,;qoNJH\NEr\2aGe!Y9muiPALu8W39d]$>QY2N(Gjh9V[;IbEmrnFe;[JHIfA/=2KCN7c`#=sRfR;<'rRXf/&C@*omreBL)hd\5IAatF!cSDp&Ue?56_D_+=I8Rok!s&p)qX[M1,IbW@'djghZ5o&jh+O@,R5;2Br):M0A^]3Wr$c\IfGPMX[N\hIN&p17p?i&CeWo?bE:,ZQ4)3Ma7a\JAMIr5A;tm[lYY$YJo%Hlfn5fb1FO-l=<2D@Ms!>Q06UfI]LNel+fpus/nLVY&glob!"n35F'$L8>&IqJ>X<,QE\&ELIhX"bV*rs4E7j@HmIshI@%e\eAH1QFAq;'gA'^_$]d[H1-Lkjo3n^0_Pbbhj9X9UnL23tM'?idE]<eYKBqVeOes(X!Fh:ObN4"E''[I=8^Yk4ihoXB``jOR8QN!;B)Z3-p7gkr`-5-CKF]]^:i,3ORgI8qTW@FcF];F2)l_6>IaQI7QX'^=[1)UTFEU:Z>MZMQKlp"q<]Aq</jQ^Q79!i,7*hSs.?M.;J/.CfEBMKJ:C9,6fLCaeV7s2?Y-aiC:]+/abdR$R])I4M51#CPmGoq@h%k-LmFW^B>-)J_h>EVbgYHq)6"?Kq<lO*`I_:%8bH=P<XHtlISI9(a2TRsld5*uurnH:uVapDY0q;Hsr/s<U.]-&MV4`c@E9'U`gg+_ipC;[!I6UTJef4#N'R(#%HHblVca)Fu%\#i!QJ-93/.HPg^)J)r.$LRI:&gRl8a*t'sVU<=Z=IRQ!0^&VtiK$0A^k]#l9ENA:Nru<5qEZM#70u4F=RLU*7kFn,%kMk"oK:5HI@e5_3R'/9G^HsQ&uB".:odjc3u+M.pb.=#E+f~>
102
- endstream
103
- endobj
104
- 21 0 obj
105
- << /Type /Page
106
- /Parent 1 0 R
107
- /MediaBox [ 0 0 612 792 ]
108
- /Resources 3 0 R
109
- /Contents 20 0 R
110
- >>
111
- endobj
112
- 22 0 obj
113
- << /Length 798 /Filter [ /ASCII85Decode /FlateDecode ]
114
- >>
115
- stream
116
- Gat%"95g:b&AI`dk3*ej@:(Q*PIccX2,]ndjj<^Om1!CPL(l_/o'\Y&QN[UU[U_,1IZIVKcecUskLf[tq*]9$5h]N"HBD!N#c,7C+j91E.LG2<$4TYsLNaDY<so2=>S',F5(Y6Ypn^eS"io^*`&m`SPN2ct=[b-Yb6r0^A=:1PD"qSeHhXhR%G#i:p*S+%k"oa)^OY2QJ$$neQ&!pO(F0E@ei]^\orQbV=)R!r()dJM#ue&1as.NfXA*NI-_XN/$4h"4&h%N'Y=ONb#5+ac:j)Spk)Xf=CQnDHp='=nBL&dn"![kk4VB/:K^[o)V\Wpi-H3g&[e`.f%WNpCVhE'/l,#f1QHp=YD3f+WEJG#M9&Sb)LdPhN%N+@S&>pPW0^E]7]s1(U]#:FA0I8Q1#;07NKLN^KUE.Vu*Ap`%`hc+pJ5,<f#i,)7i7L%@4T3JUnGG`oE0k$S;J]#L#6Y)AlL_Mgi45C8?nS:m8Z=F13$8M)o=T7^1YQP.>,q(QflYgj5tFScc`l('Xj(TE*;A^'Q82oIAkX=P!eD"13o0TIB5Lsne%@Aic)rdJ[9sOY0cZE_,(q[I'PA_MC@#63g6er[OUD-1<5;o89d`AAZIDI[U4AG@L1_=KHR#ji`c\W^1<*U=s0@#npGf:q,P;dKZ5KUN-aK8?:[LQGD1QPD&rY`mLC!(IC23X;Ui'V8[mAM^-7T=i'!euB1l;P[8oUOSUG^Mur;!HKl)$L'W3AApr*kiCM#"cjd=X&LPM:=jFJ6%S9jDVG2Q2FY2[d=N`BV$_G$k4N<d!pE~>
117
- endstream
118
- endobj
119
- 23 0 obj
120
- << /Type /Page
121
- /Parent 1 0 R
122
- /MediaBox [ 0 0 612 792 ]
123
- /Resources 3 0 R
124
- /Contents 22 0 R
125
- /Annots 24 0 R
126
- >>
127
- endobj
128
- 24 0 obj
129
- [
130
- 25 0 R
131
- 26 0 R
132
- ]
133
- endobj
134
- 25 0 obj
135
- << /Type /Annot
136
- /Subtype /Link
137
- /Rect [ 90.0 629.666 259.296 617.666 ]
138
- /C [ 0 0 0 ]
139
- /Border [ 0 0 0 ]
140
- /A << /URI (http://en.wikipedia.org/wiki/Decision_tree)
141
- /S /URI >>
142
- /H /I
143
- >>
144
- endobj
145
- 26 0 obj
146
- << /Type /Annot
147
- /Subtype /Link
148
- /Rect [ 262.296 629.666 434.94 617.666 ]
149
- /C [ 0 0 0 ]
150
- /Border [ 0 0 0 ]
151
- /A << /URI (http://en.wikipedia.org/wiki/ID3_algorithm)
152
- /S /URI >>
153
- /H /I
154
- >>
155
- endobj
156
- 28 0 obj
157
- <<
158
- /Title (\376\377\0\61\0\40\0\111\0\156\0\164\0\162\0\157\0\144\0\165\0\143\0\164\0\151\0\157\0\156\0\40\0\164\0\157\0\40\0\111\0\104\0\63\0\40\0\141\0\154\0\147\0\157\0\162\0\151\0\164\0\150\0\155)
159
- /Parent 27 0 R
160
- /Next 29 0 R
161
- /A 9 0 R
162
- >> endobj
163
- 29 0 obj
164
- <<
165
- /Title (\376\377\0\62\0\40\0\115\0\141\0\162\0\153\0\145\0\164\0\151\0\156\0\147\0\40\0\164\0\141\0\162\0\147\0\145\0\164\0\40\0\163\0\164\0\162\0\141\0\164\0\145\0\147\0\171\0\40\0\145\0\170\0\141\0\155\0\160\0\154\0\145\0\40\0\165\0\163\0\151\0\156\0\147\0\40\0\111\0\104\0\63\0\40\0\104\0\145\0\143\0\151\0\163\0\151\0\157\0\156\0\40\0\124\0\162\0\145\0\145\0\163\0\40\0\151\0\156\0\40\0\122\0\165\0\142\0\171)
166
- /Parent 27 0 R
167
- /Prev 28 0 R
168
- /Next 30 0 R
169
- /A 11 0 R
170
- >> endobj
171
- 30 0 obj
172
- <<
173
- /Title (\376\377\0\63\0\40\0\102\0\145\0\164\0\164\0\145\0\162\0\40\0\144\0\141\0\164\0\141\0\40\0\154\0\157\0\141\0\144\0\151\0\156\0\147)
174
- /Parent 27 0 R
175
- /Prev 29 0 R
176
- /Next 31 0 R
177
- /A 13 0 R
178
- >> endobj
179
- 31 0 obj
180
- <<
181
- /Title (\376\377\0\64\0\40\0\101\0\40\0\147\0\157\0\157\0\144\0\40\0\164\0\151\0\160\0\40\0\146\0\157\0\162\0\40\0\144\0\141\0\164\0\141\0\40\0\145\0\166\0\141\0\154\0\165\0\141\0\164\0\151\0\157\0\156)
182
- /Parent 27 0 R
183
- /Prev 30 0 R
184
- /Next 32 0 R
185
- /A 15 0 R
186
- >> endobj
187
- 32 0 obj
188
- <<
189
- /Title (\376\377\0\65\0\40\0\115\0\157\0\162\0\145\0\40\0\141\0\142\0\157\0\165\0\164\0\40\0\111\0\104\0\63\0\40\0\141\0\156\0\144\0\40\0\144\0\145\0\143\0\151\0\163\0\151\0\157\0\156\0\40\0\164\0\162\0\145\0\145\0\163)
190
- /Parent 27 0 R
191
- /Prev 31 0 R
192
- /A 17 0 R
193
- >> endobj
194
- 33 0 obj
195
- << /Type /Font
196
- /Subtype /Type1
197
- /Name /F3
198
- /BaseFont /Helvetica-Bold
199
- /Encoding /WinAnsiEncoding >>
200
- endobj
201
- 34 0 obj
202
- << /Type /Font
203
- /Subtype /Type1
204
- /Name /F5
205
- /BaseFont /Times-Roman
206
- /Encoding /WinAnsiEncoding >>
207
- endobj
208
- 35 0 obj
209
- << /Type /Font
210
- /Subtype /Type1
211
- /Name /F1
212
- /BaseFont /Helvetica
213
- /Encoding /WinAnsiEncoding >>
214
- endobj
215
- 36 0 obj
216
- << /Type /Font
217
- /Subtype /Type1
218
- /Name /F9
219
- /BaseFont /Courier
220
- /Encoding /WinAnsiEncoding >>
221
- endobj
222
- 37 0 obj
223
- << /Type /Font
224
- /Subtype /Type1
225
- /Name /F2
226
- /BaseFont /Helvetica-Oblique
227
- /Encoding /WinAnsiEncoding >>
228
- endobj
229
- 38 0 obj
230
- << /Type /Font
231
- /Subtype /Type1
232
- /Name /F7
233
- /BaseFont /Times-Bold
234
- /Encoding /WinAnsiEncoding >>
235
- endobj
236
- 1 0 obj
237
- << /Type /Pages
238
- /Count 4
239
- /Kids [6 0 R 19 0 R 21 0 R 23 0 R ] >>
240
- endobj
241
- 2 0 obj
242
- << /Type /Catalog
243
- /Pages 1 0 R
244
- /Outlines 27 0 R
245
- /PageMode /UseOutlines
246
- >>
247
- endobj
248
- 3 0 obj
249
- <<
250
- /Font << /F3 33 0 R /F5 34 0 R /F1 35 0 R /F9 36 0 R /F2 37 0 R /F7 38 0 R >>
251
- /ProcSet [ /PDF /ImageC /Text ] >>
252
- endobj
253
- 9 0 obj
254
- <<
255
- /S /GoTo
256
- /D [19 0 R /XYZ 85.0 659.0 null]
257
- >>
258
- endobj
259
- 11 0 obj
260
- <<
261
- /S /GoTo
262
- /D [19 0 R /XYZ 85.0 519.466 null]
263
- >>
264
- endobj
265
- 13 0 obj
266
- <<
267
- /S /GoTo
268
- /D [21 0 R /XYZ 85.0 520.96 null]
269
- >>
270
- endobj
271
- 15 0 obj
272
- <<
273
- /S /GoTo
274
- /D [21 0 R /XYZ 85.0 356.826 null]
275
- >>
276
- endobj
277
- 17 0 obj
278
- <<
279
- /S /GoTo
280
- /D [23 0 R /XYZ 85.0 659.0 null]
281
- >>
282
- endobj
283
- 27 0 obj
284
- <<
285
- /First 28 0 R
286
- /Last 32 0 R
287
- >> endobj
288
- xref
289
- 0 39
290
- 0000000000 65535 f
291
- 0000009297 00000 n
292
- 0000009376 00000 n
293
- 0000009468 00000 n
294
- 0000000015 00000 n
295
- 0000000071 00000 n
296
- 0000000814 00000 n
297
- 0000000934 00000 n
298
- 0000000987 00000 n
299
- 0000009602 00000 n
300
- 0000001122 00000 n
301
- 0000009665 00000 n
302
- 0000001258 00000 n
303
- 0000009731 00000 n
304
- 0000001394 00000 n
305
- 0000009796 00000 n
306
- 0000001531 00000 n
307
- 0000009862 00000 n
308
- 0000001668 00000 n
309
- 0000003584 00000 n
310
- 0000003692 00000 n
311
- 0000005556 00000 n
312
- 0000005664 00000 n
313
- 0000006554 00000 n
314
- 0000006677 00000 n
315
- 0000006711 00000 n
316
- 0000006904 00000 n
317
- 0000009926 00000 n
318
- 0000007099 00000 n
319
- 0000007360 00000 n
320
- 0000007852 00000 n
321
- 0000008070 00000 n
322
- 0000008351 00000 n
323
- 0000008635 00000 n
324
- 0000008748 00000 n
325
- 0000008858 00000 n
326
- 0000008966 00000 n
327
- 0000009072 00000 n
328
- 0000009188 00000 n
329
- trailer
330
- <<
331
- /Size 39
332
- /Root 2 0 R
333
- /Info 4 0 R
334
- >>
335
- startxref
336
- 9977
337
- %%EOF
@@ -1,446 +0,0 @@
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>Backpropagation neural networks in ruby :: ai4r</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
- <!--+
27
- |end group logo
28
- +-->
29
- <!--+
30
- |start Project Logo
31
- +-->
32
- <div class="projectlogoA1">
33
- <a href="http://ai4r.rubyforge.org/"><img class="logoImage" alt="ai4r" src="images/ai4r-logo.png" title="Artificial Intelligence for Ruby"></a>
34
- </div>
35
- <!--+
36
- |end Project Logo
37
- +-->
38
- <!--+
39
- |start Search
40
- +-->
41
- <div class="searchbox">
42
- <div class="roundtopsmall">
43
- <form target="_top" action="http://www.google.com/custom" method="get">
44
- <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">
45
- </form>
46
- </div>
47
- </div>
48
- <!--+
49
- |end search
50
- +-->
51
- <!--+
52
- |start Tabs
53
- +-->
54
- <ul id="tabs">
55
- <li class="current">
56
- <a class="selected" href="index.html">Home</a>
57
- </li>
58
- </ul>
59
- <!--+
60
- |end Tabs
61
- +-->
62
- </div>
63
- </div>
64
- <div id="main">
65
- <div id="publishedStrip">
66
- <!--+
67
- |start Subtabs
68
- +-->
69
- <div id="level2tabs"></div>
70
- <!--+
71
- |end Endtabs
72
- +-->
73
- <script type="text/javascript"><!--
74
- document.write("Last Published: " + document.lastModified);
75
- // --></script>
76
- </div>
77
- <!--+
78
- |breadtrail
79
- +-->
80
- <div class="breadtrail">
81
-
82
- &nbsp;
83
- </div>
84
- <!--+
85
- |start Menu, mainarea
86
- +-->
87
- <!--+
88
- |start Menu
89
- +-->
90
- <div id="menu">
91
- <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>
92
- <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
93
- <div class="menuitem">
94
- <a href="index.html" title="ai4r - Artificial Intelligence for Ruby">Index</a>
95
- </div>
96
- <div class="menuitem">
97
- <a href="geneticAlgorithms.html" title="Genetic Algorithms in ruby">Genetic Algorithms</a>
98
- </div>
99
- <div class="menuitem">
100
- <a href="machineLearning.html" title="ID3 Decision Trees in ruby">Machine Learning</a>
101
- </div>
102
- <div class="menupage">
103
- <div class="menupagetitle">Neural Networks</div>
104
- </div>
105
- <div class="menuitem">
106
- <a href="downloads.html" title="ai4r - Download Files">Downloads</a>
107
- </div>
108
- <div class="menuitem">
109
- <a href="svn.html" title="ai4r Subversion repository">Subversion (svn)</a>
110
- </div>
111
- <div class="menuitem">
112
- <a href="wholesite.pdf">ai4r project PDF</a>
113
- </div>
114
- </div>
115
- <div id="credit">
116
- <script type="text/javascript">
117
- google_ad_client = "pub-2578934938711895";
118
- google_ad_slot = "6111091580";
119
- google_ad_width = 125;
120
- google_ad_height = 125;
121
- </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
122
- <hr>
123
- </div>
124
- <div id="roundbottom">
125
- <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
126
- <!--+
127
- |alternative credits
128
- +-->
129
- <div id="credit2"></div>
130
- </div>
131
- <!--+
132
- |end Menu
133
- +-->
134
- <!--+
135
- |start content
136
- +-->
137
- <div id="content">
138
- <div title="Portable Document Format" class="pdflink">
139
- <a class="dida" href="neuralNetworks.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
140
- PDF</a>
141
- </div>
142
- <h1>Backpropagation neural networks in ruby :: ai4r</h1>
143
- <div id="minitoc-area">
144
- <ul class="minitoc">
145
- <li>
146
- <a href="#nn-Introduction">Introduction to Neural Networks in Ruby</a>
147
- </li>
148
- <li>
149
- <a href="#nn-HowTo">How to use Backpropagation Neural Networks in Ruby</a>
150
- </li>
151
- <li>
152
- <a href="#nn-example">Example using ai4r Backpropagation network in ruby</a>
153
- </li>
154
- <li>
155
- <a href="#nn-custom">Customizing your neural network in ai4r</a>
156
- </li>
157
- <li>
158
- <a href="#nn-more">More about Neural Networks and Backpropagation</a>
159
- </li>
160
- </ul>
161
- </div>
162
-
163
- <a name="N1000D"></a><a name="nn-Introduction"></a>
164
- <h2 class="boxed">Introduction to Neural Networks in Ruby</h2>
165
- <div class="section">
166
- <p>
167
- The utility of artificial neural network models lies in the fact that they can be used to infer a function from observations. This is particularly useful in applications where the complexity of the data or task makes the design of such a function by hand impractical. Neural Networks are being used in many businesses and applications. Their ability to learn by example makes them attractive in environments where the business rules are either not well defined or are hard to enumerate and define. Many people believe that Neural Networks can only solve toy problems. Give them a try, and let you decide if they are good enough to solve your needs.
168
- </p>
169
- <p>
170
- In this module you will find an implementation of neural networks using the Backpropagation is a supervised learning technique (described by Paul Werbos in 1974, and further developed by David E. Rumelhart, Geoffrey E. Hinton and Ronald J. Williams in 1986)
171
- </p>
172
- </div>
173
-
174
- <a name="N1001A"></a><a name="nn-HowTo"></a>
175
- <h2 class="boxed">How to use Backpropagation Neural Networks in Ruby</h2>
176
- <div class="section">
177
- <pre class="code">
178
-
179
- # Create the network
180
- net = Backpropagation.new([4, 3, 2]) # 4 inputs
181
- # 1 hidden layer with 3 neurons,
182
- # 4 outputs
183
- # Train the network
184
- 1..upto(100) do |i|
185
- net.train(example[i], result[i])
186
- end
187
-
188
- # Use it: Evaluate data with the trained network
189
- net.eval([12, 48, 12, 25]) # =&gt; [34, 22]
190
-
191
- </pre>
192
- </div>
193
-
194
-
195
- <a name="N10025"></a><a name="nn-example"></a>
196
- <h2 class="boxed">Example using ai4r Backpropagation network in ruby</h2>
197
- <div class="section">
198
- <p>
199
- Let's imagine that we have to implement a program to identify simple patterns (triangles, squares, crosses, etc). The main problem is that this program must be resistant to random noise in the image (pixels with wrong
200
- values) and line noise (similar to the unwanted direct current that we usually have in a signal).</p>
201
- <p>
202
- We can take an example of each pattern to be recognized, and train a neural network to identify them.
203
- </p>
204
- <p>
205
- We create a network with the following architecture: 256 input neurons, 128 neurons in a hidden layer, 3 output neurons. We feed this network with 16x16 matrices (in fact will convert them to vectors of length 256). Each pixel is represented with a number from 0 (white pixel) to 10 (black pixel). The output of this network if a 3 vector of dimension 3, where ideally:</p>
206
- <ul>
207
-
208
- <li>(1, 0, 0) for triangles</li>
209
-
210
- <li>(0, 1, 0) for squares</li>
211
-
212
- <li>(0, 0, 1) for crosses</li>
213
-
214
- </ul>
215
- <p>We train our backpropagation neural network using the following examples:</p>
216
- <table class="ForrestTable" cellspacing="1" cellpadding="4">
217
-
218
- <caption>Training patterns</caption>
219
-
220
- <tr>
221
-
222
- <td colspan="1" rowspan="1"><img alt="Triangule training example" src="/images/t.png"></td>
223
- <td colspan="1" rowspan="1"><img alt="Square training example" src="/images/s.png"></td>
224
- <td colspan="1" rowspan="1"><img alt="Cross training example" src="/images/c.png"></td>
225
-
226
- </tr>
227
-
228
- </table>
229
- <p>And we repeat the training 20 times.</p>
230
- <p>
231
- The results we got when we evaluate patterns with our trained network are:
232
- </p>
233
- <ul>
234
-
235
- <li>Evaluating the training patterns with the trained network:
236
- <ol>
237
-
238
- <li>
239
- <img alt="Triangule training example" src="/images/t.png">
240
- [0.98, 0.03, 0.01] =&gt; TRIANGLE </li>
241
-
242
- <li>
243
- <img alt="Square training example" src="/images/s.png">
244
- [0.00, 0.96, 0.03] =&gt; SQUARE </li>
245
-
246
- <li>
247
- <img alt="Cross training example" src="/images/c.png">
248
- [0.00, 0.00, 0.99] =&gt; CROSS </li>
249
-
250
- </ol>
251
-
252
- </li>
253
-
254
- <li>Evaluating the patterns with random noise with the trained network:
255
- <ol>
256
-
257
- <li>
258
- <img alt="Triangule pattern with random noise" src="/images/t_wn.png"> [0.98, 0.01, 0.01] =&gt; TRIANGLE </li>
259
-
260
- <li>
261
- <img alt="Square pattern with random noise" src="/images/s_wn.png"> [0.00, 0.96, 0.02] =&gt; SQUARE </li>
262
-
263
- <li>
264
- <img alt="Cross pattern with random noise" src="/images/c_wn.png"> [0.00, 0.00, 0.98] =&gt; CROSS </li>
265
-
266
- </ol>
267
-
268
- </li>
269
-
270
- <li>Evaluating the patterns with line noise with the trained network:
271
- <ol>
272
-
273
- <li>
274
- <img alt="Triangule pattern with line noise" src="/images/t_wbn.png"> [0.62, 0.00, 0.02] =&gt; TRIANGLE </li>
275
-
276
- <li>
277
- <img alt="Square pattern with line noise" src="/images/s_wbn.png"> [0.00, 0.75, 0.01] =&gt; SQUARE </li>
278
-
279
- <li>
280
- <img alt="Cross pattern with line noise" src="/images/c_wbn.png"> [0.00, 0.00, 0.98] =&gt; CROSS </li>
281
-
282
- </ol>
283
-
284
- </li>
285
-
286
- </ul>
287
- <p>These results are very satisfactory. The network could sucessfully identify the patterns despite the noise introduced to them. In fact, one of the most popular uses of neural networks in business
288
- applications is OCR (opticar character recognition).</p>
289
- <p>This is the source code used to elaborate this example (You can find it inside the zip file):</p>
290
- <pre class="code">
291
-
292
- require File.dirname(__FILE__) + '/training_patterns'
293
- require File.dirname(__FILE__) + '/patterns_with_noise'
294
- require File.dirname(__FILE__) + '/patterns_with_base_noise'
295
- require File.dirname(__FILE__) + '/../../lib/neural_network/backpropagation'
296
-
297
- net = NeuralNetwork::Backpropagation.new([256, 128, 3])
298
-
299
- tr_input = TRIANGLE.flatten.collect { |input| input.to_f / 10}
300
- sq_input = SQUARE.flatten.collect { |input| input.to_f / 10}
301
- cr_input = CROSS.flatten.collect { |input| input.to_f / 10}
302
-
303
- tr_with_noise = TRIANGLE_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
304
- sq_with_noise = SQUARE_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
305
- cr_with_noise = CROSS_WITH_NOISE.flatten.collect { |input| input.to_f / 10}
306
-
307
- tr_with_base_noise = TRIANGLE_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
308
- sq_with_base_noise = SQUARE_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
309
- cr_with_base_noise = CROSS_WITH_BASE_NOISE.flatten.collect { |input| input.to_f / 10}
310
-
311
- puts "Training the network, please wait."
312
- 20.times do
313
- net.train(tr_input, [1,0,0])
314
- net.train(sq_input, [0,1,0])
315
- net.train(cr_input, [0,0,1])
316
- end
317
-
318
- def result_label(result)
319
- if result[0] &gt; result[1] &amp;&amp; result[0] &gt; result[2]
320
- "TRIANGLE"
321
- elsif result[1] &gt; result[2]
322
- "SQUARE"
323
- else
324
- "CROSS"
325
- end
326
- end
327
-
328
- puts "Training Examples"
329
- puts "#{net.eval(tr_input).inspect} =&gt; #{result_label(net.eval(tr_input))}"
330
- puts "#{net.eval(sq_input).inspect} =&gt; #{result_label(net.eval(sq_input))}"
331
- puts "#{net.eval(cr_input).inspect} =&gt; #{result_label(net.eval(cr_input))}"
332
- puts "Examples with noise"
333
- puts "#{net.eval(tr_with_noise).inspect} =&gt; #{result_label(net.eval(tr_with_noise))}"
334
- puts "#{net.eval(sq_with_noise).inspect} =&gt; #{result_label(net.eval(sq_with_noise))}"
335
- puts "#{net.eval(cr_with_noise).inspect} =&gt; #{result_label(net.eval(cr_with_noise))}"
336
- puts "Examples with base noise"
337
- puts "#{net.eval(tr_with_base_noise).inspect} =&gt; #{result_label(net.eval(tr_with_base_noise))}"
338
- puts "#{net.eval(sq_with_base_noise).inspect} =&gt; #{result_label(net.eval(sq_with_base_noise))}"
339
- puts "#{net.eval(cr_with_base_noise).inspect} =&gt; #{result_label(net.eval(cr_with_base_noise))}"
340
-
341
- </pre>
342
- </div>
343
-
344
-
345
- <a name="N100C6"></a><a name="nn-custom"></a>
346
- <h2 class="boxed">Customizing your neural network in ai4r</h2>
347
- <div class="section">
348
- <p>Sometime for a given problem, you will have to "play around" with some parameters to
349
- get to a solution. This parameters are:</p>
350
- <p>
351
- <strong>threshold</strong>: A real number which we will call Threshold. Experiments have shown that best values for q are between 0.25 and 1. You can optionally pass this parameter to the initialization method of your network.</p>
352
- <p>
353
- <strong>lambda</strong>: The Learning Rate: a real number, usually between 0.05 and 0.25. You can optionally pass this parameter to the initialization method of your network.</p>
354
- <p>
355
- <strong>momentum</strong>: A momentum will avoid oscillations during learning, converging to a solution in less iterations. You can optionally pass this parameter to the initialization method of your network.</p>
356
- <p>
357
- <strong>transference function</strong>: By default, f(x) = 1/(1 + e^(-x)).
358
- This function is called "Sigmoid function". You can see it like a
359
- "smoothed" version of the "Heaviside step function". It will always provide a
360
- value between 0 and 1. </p>
361
- <p>
362
- <img alt="Sigmoid function" src="images/sigmoid.png"></p>
363
- <p>
364
- Sometimes you will have better results with f(x) = x. You can change the transference function from the default sigmoidal function to the linear one, overriding NeuralNetwork::Neuron.f and NeuralNetwork::Neuron.f_prime (derived function
365
- of f):</p>
366
- <pre class="code">
367
-
368
- class NeuralNetwork::Neuron
369
- def self.f(x)
370
- x
371
- end
372
- def self.f_prime(x)
373
- 1
374
- end
375
- end
376
-
377
- </pre>
378
- </div>
379
-
380
-
381
- <a name="N100F0"></a><a name="nn-more"></a>
382
- <h2 class="boxed">More about Neural Networks and Backpropagation</h2>
383
- <div class="section">
384
- <ul>
385
-
386
- <li>
387
-
388
- <a href="http://en.wikipedia.org/wiki/Artificial_neural_network">Wikipedia article on Artificial Neural Networks</a>
389
-
390
- </li>
391
-
392
- <li>
393
-
394
- <a href="http://en.wikipedia.org/wiki/Backpropagation">Wikipedia article on Backpropagation Algorithm</a>
395
-
396
- </li>
397
-
398
- <li>
399
-
400
- <a href="http://www.tek271.com/articles/neuralNet/IntoToNeuralNets.html">Neural Networks - An Introduction by Abdul Habra</a>
401
-
402
- </li>
403
-
404
- <li>
405
-
406
- <a href="http://galaxy.agh.edu.pl/~vlsi/AI/backp_t_en/backprop.html">A graphical explanation of the
407
- backpropagation algorithm by Mariusz Bernacki and Przemysław Włodarczyk</a>
408
-
409
- </li>
410
-
411
- </ul>
412
- </div>
413
-
414
-
415
- </div>
416
- <!--+
417
- |end content
418
- +-->
419
- <div class="clearboth">&nbsp;</div>
420
- </div>
421
- <div id="footer">
422
- <!--+
423
- |start bottomstrip
424
- +-->
425
- <div class="lastmodified">
426
- <script type="text/javascript"><!--
427
- document.write("Last Published: " + document.lastModified);
428
- // --></script>
429
- </div>
430
- <div class="copyright">
431
- Copyright &copy;
432
- 2007-2008 Sergio Fierens</div>
433
- <div class="host">
434
- <a href="http://rubyforge.org/projects/ai4r/"><img class="logoImage" alt="" src="images/rubyforge.png"></a>
435
- </div>
436
- <!--+
437
- |end bottomstrip
438
- +-->
439
- </div>
440
- <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
441
- var pageTracker = _gat._getTracker("UA-3234625-1");
442
- pageTracker._initData();
443
- pageTracker._trackPageview();
444
- </script>
445
- </body>
446
- </html>