ai4r 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +48 -0
- data/examples/decision_trees/data_set.csv +121 -0
- data/examples/decision_trees/id3_example.rb +31 -0
- data/examples/decision_trees/results.txt +29 -0
- data/examples/genetic_algorithm/genetic_algorithm_example.rb +39 -0
- data/examples/genetic_algorithm/travel_cost.csv +16 -0
- data/examples/neural_network/backpropagation_example.rb +65 -0
- data/examples/neural_network/patterns_with_base_noise.rb +68 -0
- data/examples/neural_network/patterns_with_noise.rb +66 -0
- data/examples/neural_network/training_patterns.rb +68 -0
- data/lib/decision_tree/id3.rb +354 -0
- data/lib/genetic_algorithm/genetic_algorithm.rb +268 -0
- data/lib/neural_network/backpropagation.rb +259 -0
- data/site/build/site/en/broken-links.xml +2 -0
- data/site/build/site/en/downloads.html +187 -0
- data/site/build/site/en/downloads.pdf +151 -0
- data/site/build/site/en/geneticAlgorithms.html +564 -0
- data/site/build/site/en/geneticAlgorithms.pdf +911 -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/instruction_arrow.png +0 -0
- data/site/build/site/en/images/my_email.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 +258 -0
- data/site/build/site/en/index.pdf +306 -0
- data/site/build/site/en/linkmap.html +231 -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 +325 -0
- data/site/build/site/en/machineLearning.pdf +337 -0
- data/site/build/site/en/neuralNetworks.html +446 -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 +223 -0
- data/site/build/site/en/svn.pdf +239 -0
- data/site/build/site/en/wholesite.pdf +1686 -0
- data/site/build/tmp/brokenlinks.xml +2 -0
- data/site/build/tmp/build-info.xml +5 -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/input.xmap +32 -0
- data/site/build/tmp/internal.xmap +32 -0
- data/site/build/tmp/locationmap.xml +29 -0
- data/site/build/tmp/output.xmap +38 -0
- data/site/build/tmp/pluginlist2fetchbuild.xml +144 -0
- data/site/build/tmp/plugins-1.xml +212 -0
- data/site/build/tmp/plugins-2.xml +347 -0
- data/site/build/tmp/projfilters.properties +41 -0
- data/site/build/tmp/resources.xmap +32 -0
- data/site/build/webapp/WEB-INF/logs/access.log +0 -0
- data/site/build/webapp/WEB-INF/logs/core.log +788 -0
- data/site/build/webapp/WEB-INF/logs/debug.log +0 -0
- data/site/build/webapp/WEB-INF/logs/error.log +248 -0
- data/site/build/webapp/WEB-INF/logs/flow.log +0 -0
- data/site/build/webapp/WEB-INF/logs/idgen.log +0 -0
- data/site/build/webapp/WEB-INF/logs/linkrewriter.log +0 -0
- data/site/build/webapp/WEB-INF/logs/locationmap.log +0 -0
- data/site/build/webapp/WEB-INF/logs/sitemap.log +0 -0
- data/site/build/webapp/WEB-INF/logs/xmlform.log +0 -0
- data/site/forrest.properties +152 -0
- data/site/forrest.properties.dispatcher.properties +25 -0
- data/site/forrest.properties.xml +29 -0
- data/site/src/documentation/README.txt +7 -0
- data/site/src/documentation/classes/CatalogManager.properties +62 -0
- data/site/src/documentation/content/locationmap.xml +72 -0
- data/site/src/documentation/content/xdocs/downloads.html +9 -0
- data/site/src/documentation/content/xdocs/geneticAlgorithms.xml +280 -0
- data/site/src/documentation/content/xdocs/index.xml +73 -0
- data/site/src/documentation/content/xdocs/machineLearning.xml +129 -0
- data/site/src/documentation/content/xdocs/neuralNetworks.xml +218 -0
- data/site/src/documentation/content/xdocs/site.xml +51 -0
- data/site/src/documentation/content/xdocs/svn.xml +31 -0
- data/site/src/documentation/content/xdocs/tabs.xml +35 -0
- data/site/src/documentation/resources/images/ai4r-logo.png +0 -0
- data/site/src/documentation/resources/images/c.png +0 -0
- data/site/src/documentation/resources/images/c_wbn.png +0 -0
- data/site/src/documentation/resources/images/c_wn.png +0 -0
- data/site/src/documentation/resources/images/ellipse-2.svg +30 -0
- data/site/src/documentation/resources/images/ero.gif +0 -0
- data/site/src/documentation/resources/images/europe2.png +0 -0
- data/site/src/documentation/resources/images/europe3.png +0 -0
- data/site/src/documentation/resources/images/fitness.png +0 -0
- data/site/src/documentation/resources/images/icon-a.png +0 -0
- data/site/src/documentation/resources/images/icon-b.png +0 -0
- data/site/src/documentation/resources/images/icon.png +0 -0
- data/site/src/documentation/resources/images/my_email.png +0 -0
- data/site/src/documentation/resources/images/project-logo.png +0 -0
- data/site/src/documentation/resources/images/rubyforge.png +0 -0
- data/site/src/documentation/resources/images/s.png +0 -0
- data/site/src/documentation/resources/images/s_wbn.png +0 -0
- data/site/src/documentation/resources/images/s_wn.png +0 -0
- data/site/src/documentation/resources/images/sigmoid.png +0 -0
- data/site/src/documentation/resources/images/sub-dir/icon-c.png +0 -0
- data/site/src/documentation/resources/images/t.png +0 -0
- data/site/src/documentation/resources/images/t_wbn.png +0 -0
- data/site/src/documentation/resources/images/t_wn.png +0 -0
- data/site/src/documentation/resources/schema/catalog.xcat +29 -0
- data/site/src/documentation/resources/schema/hello-v10.dtd +51 -0
- data/site/src/documentation/resources/schema/symbols-project-v10.ent +26 -0
- data/site/src/documentation/resources/stylesheets/hello2document.xsl +33 -0
- data/site/src/documentation/sitemap.xmap +66 -0
- data/site/src/documentation/skinconf.xml +418 -0
- data/site/src/documentation/translations/langcode.xml +29 -0
- data/site/src/documentation/translations/languages_de.xml +24 -0
- data/site/src/documentation/translations/languages_en.xml +24 -0
- data/site/src/documentation/translations/languages_es.xml +22 -0
- data/site/src/documentation/translations/languages_fr.xml +24 -0
- data/site/src/documentation/translations/languages_nl.xml +24 -0
- data/site/src/documentation/translations/menu.xml +33 -0
- data/site/src/documentation/translations/menu_af.xml +33 -0
- data/site/src/documentation/translations/menu_de.xml +33 -0
- data/site/src/documentation/translations/menu_es.xml +33 -0
- data/site/src/documentation/translations/menu_fr.xml +33 -0
- data/site/src/documentation/translations/menu_it.xml +33 -0
- data/site/src/documentation/translations/menu_nl.xml +33 -0
- data/site/src/documentation/translations/menu_no.xml +33 -0
- data/site/src/documentation/translations/menu_ru.xml +33 -0
- data/site/src/documentation/translations/menu_sk.xml +33 -0
- data/site/src/documentation/translations/tabs.xml +22 -0
- data/site/src/documentation/translations/tabs_de.xml +22 -0
- data/site/src/documentation/translations/tabs_es.xml +22 -0
- data/site/src/documentation/translations/tabs_fr.xml +22 -0
- data/site/src/documentation/translations/tabs_nl.xml +22 -0
- data/test/decision_tree/id3_test.rb +209 -0
- data/test/genetic_algorithm/chromosome_test.rb +55 -0
- data/test/genetic_algorithm/genetic_algorithm_test.rb +78 -0
- data/test/neural_network/backpropagation_test.rb +44 -0
- metadata +274 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
|
2
|
+
# The utility of artificial neural network
|
3
|
+
# models lies in the fact that they can be used
|
4
|
+
# to infer a function from observations.
|
5
|
+
# This is particularly useful in applications
|
6
|
+
# where the complexity of the data or task makes the
|
7
|
+
# design of such a function by hand impractical.
|
8
|
+
# Neural Networks are being used in many businesses and applications. Their
|
9
|
+
# ability to learn by example makes them attractive in environments where
|
10
|
+
# the business rules are either not well defined or are hard to enumerate and
|
11
|
+
# define. Many people believe that Neural Networks can only solve toy problems.
|
12
|
+
# Give them a try, and let you decide if they are good enough to solve your
|
13
|
+
# needs.
|
14
|
+
#
|
15
|
+
# In this module you will find an implementation of neural networks
|
16
|
+
# using the Backpropagation is a supervised learning technique (described
|
17
|
+
# by Paul Werbos in 1974, and further developed by David E.
|
18
|
+
# Rumelhart, Geoffrey E. Hinton and Ronald J. Williams in 1986)
|
19
|
+
#
|
20
|
+
# More about neural networks and backpropagation:
|
21
|
+
#
|
22
|
+
# * http://en.wikipedia.org/wiki/Backpropagation
|
23
|
+
# * http://en.wikipedia.org/wiki/Neural_networks
|
24
|
+
#
|
25
|
+
# Author:: Sergio Fierens
|
26
|
+
# License:: MPL 1.1
|
27
|
+
# Project:: ai4r
|
28
|
+
# Url:: http://ai4r.rubyforge.org/
|
29
|
+
#
|
30
|
+
# Specials thanks to John Miller, for several bugs fixes and comments in the
|
31
|
+
# Backpropagation implementation
|
32
|
+
#
|
33
|
+
# You can redistribute it and/or modify it under the terms of
|
34
|
+
# the Mozilla Public License version 1.1 as published by the
|
35
|
+
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
|
36
|
+
#
|
37
|
+
|
38
|
+
module NeuralNetwork
|
39
|
+
|
40
|
+
# = Introduction
|
41
|
+
#
|
42
|
+
# This is an implementation of neural networks
|
43
|
+
# using the Backpropagation is a supervised learning technique (described
|
44
|
+
# by Paul Werbos in 1974, and further developed by David E.
|
45
|
+
# Rumelhart, Geoffrey E. Hinton and Ronald J. Williams in 1986)
|
46
|
+
#
|
47
|
+
# = How to use it
|
48
|
+
#
|
49
|
+
# # Create the network
|
50
|
+
# net = Backpropagation.new([4, 3, 2]) # 4 inputs
|
51
|
+
# # 1 hidden layer with 3 neurons,
|
52
|
+
# # 2 outputs
|
53
|
+
# # Train the network
|
54
|
+
# 1..upto(100) do |i|
|
55
|
+
# net.train(example[i], result[i])
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# # Use it: Evaluate data with the trained network
|
59
|
+
# net.eval([12, 48, 12, 25]) # => [0.86, 0.01]
|
60
|
+
#
|
61
|
+
class Backpropagation
|
62
|
+
|
63
|
+
DEFAULT_BETA = 0.5
|
64
|
+
DEFAULT_LAMBDA = 0.25
|
65
|
+
DEFAULT_THRESHOLD = 0.66
|
66
|
+
|
67
|
+
# Creates a new network specifying the its architecture.
|
68
|
+
# E.g.
|
69
|
+
#
|
70
|
+
# net = Backpropagation.new([4, 3, 2]) # 4 inputs
|
71
|
+
# # 1 hidden layer with 3 neurons,
|
72
|
+
# # 2 outputs
|
73
|
+
# net = Backpropagation.new([2, 3, 3, 4]) # 2 inputs
|
74
|
+
# # 2 hidden layer with 3 neurons each,
|
75
|
+
# # 4 outputs
|
76
|
+
# net = Backpropagation.new([2, 1]) # 2 inputs
|
77
|
+
# # No hidden layer
|
78
|
+
# # 1 output
|
79
|
+
#
|
80
|
+
# Optionally you can customize certain parameters:
|
81
|
+
#
|
82
|
+
# threshold = A real number which we will call Threshold.
|
83
|
+
# Experiments have shown that best values for q are between 0.25 and 1.
|
84
|
+
#
|
85
|
+
# lambda = The Learning Rate: a real number, usually between 0.05 and 0.25.
|
86
|
+
#
|
87
|
+
# momentum = A momentum will avoid oscillations during learning, converging
|
88
|
+
# to a solution in less iterations.
|
89
|
+
def initialize(layer_sizes, threshold=DEFAULT_THRESHOLD, lambda=DEFAULT_LAMBDA, momentum=DEFAULT_BETA)
|
90
|
+
@neurons = []
|
91
|
+
layer_sizes.reverse.each do |layer_size|
|
92
|
+
layer = []
|
93
|
+
layer_size.times { layer << Neuron.new(@neurons.last, threshold, lambda, momentum) }
|
94
|
+
@neurons << layer
|
95
|
+
end
|
96
|
+
@neurons.reverse!
|
97
|
+
end
|
98
|
+
|
99
|
+
# Evaluates the input.
|
100
|
+
# E.g.
|
101
|
+
# net = Backpropagation.new([4, 3, 2])
|
102
|
+
# net.eval([25, 32.3, 12.8, 1.5])
|
103
|
+
# # => [0.83, 0.03]
|
104
|
+
def eval(input)
|
105
|
+
#check input size
|
106
|
+
if(input.length != @neurons.first.length)
|
107
|
+
raise "Wrong input dimension. Expected: #{@neurons.first.length}"
|
108
|
+
end
|
109
|
+
#Present input
|
110
|
+
input.each_index do |input_index|
|
111
|
+
@neurons.first[input_index].propagate(input[input_index])
|
112
|
+
end
|
113
|
+
#Propagate
|
114
|
+
@neurons[1..-1].each do |layer|
|
115
|
+
layer.each {|neuron| neuron.propagate}
|
116
|
+
end
|
117
|
+
output = []
|
118
|
+
@neurons.last.each { |neuron| output << neuron.state }
|
119
|
+
return output
|
120
|
+
end
|
121
|
+
|
122
|
+
# This method trains the network using the backpropagation algorithm.
|
123
|
+
#
|
124
|
+
# input: Networks input
|
125
|
+
#
|
126
|
+
# output: Expected output for the given input.
|
127
|
+
def train(input, output)
|
128
|
+
#Eval input
|
129
|
+
eval(input)
|
130
|
+
#Set expected output
|
131
|
+
output.each_index do |output_index|
|
132
|
+
@neurons.last[output_index].expected_output = output[output_index]
|
133
|
+
end
|
134
|
+
#Calculate error
|
135
|
+
@neurons.reverse.each do |layer|
|
136
|
+
layer.each {|neuron| neuron.calc_error}
|
137
|
+
end
|
138
|
+
#Change weight
|
139
|
+
@neurons.each do |layer|
|
140
|
+
layer.each {|neuron| neuron.change_weights }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
def print_weight
|
146
|
+
@neurons.each_index do |layer_index|
|
147
|
+
@neurons[layer_index].each_index do |neuron_index|
|
148
|
+
puts "L #{layer_index} N #{neuron_index} W #{@neurons[layer_index][neuron_index].w.inspect}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
class Neuron
|
157
|
+
|
158
|
+
attr_accessor :state
|
159
|
+
attr_accessor :error
|
160
|
+
attr_accessor :expected_output
|
161
|
+
attr_accessor :w
|
162
|
+
attr_accessor :x
|
163
|
+
|
164
|
+
def initialize(childs, threshold, lambda, momentum)
|
165
|
+
#instance state
|
166
|
+
@w = nil
|
167
|
+
@childs = childs
|
168
|
+
@error = nil
|
169
|
+
@state = 0
|
170
|
+
@pushed = 0
|
171
|
+
@last_delta = 0
|
172
|
+
@x = 0
|
173
|
+
#Parameters
|
174
|
+
@lambda = lambda
|
175
|
+
@momentum = momentum
|
176
|
+
@threshold = threshold
|
177
|
+
#init w
|
178
|
+
if(childs)
|
179
|
+
@w = []
|
180
|
+
childs.each { @w << init_weight }
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def push(x)
|
185
|
+
@pushed += x
|
186
|
+
end
|
187
|
+
|
188
|
+
def propagate(input = nil)
|
189
|
+
if(input)
|
190
|
+
input = input.to_f
|
191
|
+
@x = input
|
192
|
+
@state = input
|
193
|
+
@childs.each_index do |child_index|
|
194
|
+
@childs[child_index].push(input * @w[child_index])
|
195
|
+
end
|
196
|
+
else
|
197
|
+
@x = @pushed + @threshold
|
198
|
+
@pushed = 0
|
199
|
+
@state = Neuron.f(@x)
|
200
|
+
if @childs
|
201
|
+
@childs.each_index do |child_index|
|
202
|
+
@childs[child_index].push(@state * @w[child_index])
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def calc_error
|
209
|
+
if(!@childs && @expected_output)
|
210
|
+
@error = (@expected_output - @state)
|
211
|
+
elsif(@childs)
|
212
|
+
@error = 0
|
213
|
+
@childs.each_index do |child_index|
|
214
|
+
@error += (@childs[child_index].error * @w[child_index])
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def change_weights
|
220
|
+
return if !@childs
|
221
|
+
@childs.each_index do |child_index |
|
222
|
+
delta = @lambda * @childs[child_index].error * (@state) * Neuron.f_prime(@childs[child_index].x)
|
223
|
+
@w[child_index] += (delta + @momentum * @last_delta)
|
224
|
+
@last_delta = delta
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# Propagation function.
|
229
|
+
# By default:
|
230
|
+
# f(x) = 1/(1 + e^(-x))
|
231
|
+
# You can override it with any derivable function.
|
232
|
+
# A usually usefull one is:
|
233
|
+
# f(x) = x.
|
234
|
+
# If you override this function, you will have to override
|
235
|
+
# f_prime too.
|
236
|
+
def self.f(x)
|
237
|
+
return 1/(1+Math.exp(-1*(x)))
|
238
|
+
end
|
239
|
+
|
240
|
+
# Derived function of the propagation function (self.f)
|
241
|
+
# By default:
|
242
|
+
# f_prime(x) = f(x)(1- f(x))
|
243
|
+
# If you override f(x) with:
|
244
|
+
# f(x) = x.
|
245
|
+
# Then you must override f_prime as:
|
246
|
+
# f_prime(x) = 1
|
247
|
+
def self.f_prime(x)
|
248
|
+
val = f(x)
|
249
|
+
return val*(1-val)
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
def init_weight
|
254
|
+
rand/4
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
@@ -0,0 +1,187 @@
|
|
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
|
+
<meta name="generator" content="">
|
9
|
+
<title>Artificial intelligence for ruby :: ai4r :: download page at RubyForge</title>
|
10
|
+
<link type="text/css" href="skin/basic.css" rel="stylesheet">
|
11
|
+
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
|
12
|
+
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
|
13
|
+
<link type="text/css" href="skin/profile.css" rel="stylesheet">
|
14
|
+
<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>
|
15
|
+
<link rel="shortcut icon" href="">
|
16
|
+
</head>
|
17
|
+
<body onload="init()">
|
18
|
+
<script type="text/javascript">ndeSetTextSize();</script>
|
19
|
+
<div id="top">
|
20
|
+
<!--+
|
21
|
+
|header
|
22
|
+
+-->
|
23
|
+
<div class="header">
|
24
|
+
<!--+
|
25
|
+
|start group logo
|
26
|
+
+-->
|
27
|
+
<!--+
|
28
|
+
|end group logo
|
29
|
+
+-->
|
30
|
+
<!--+
|
31
|
+
|start Project Logo
|
32
|
+
+-->
|
33
|
+
<div class="projectlogoA1">
|
34
|
+
<a href="http://ai4r.rubyforge.org/"><img class="logoImage" alt="ai4r" src="images/ai4r-logo.png" title="Artificial Intelligence for Ruby"></a>
|
35
|
+
</div>
|
36
|
+
<!--+
|
37
|
+
|end Project Logo
|
38
|
+
+-->
|
39
|
+
<!--+
|
40
|
+
|start Search
|
41
|
+
+-->
|
42
|
+
<div class="searchbox">
|
43
|
+
<div class="roundtopsmall">
|
44
|
+
<form target="_top" action="http://www.google.com/custom" method="get">
|
45
|
+
<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">
|
46
|
+
</form>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<!--+
|
50
|
+
|end search
|
51
|
+
+-->
|
52
|
+
<!--+
|
53
|
+
|start Tabs
|
54
|
+
+-->
|
55
|
+
<ul id="tabs">
|
56
|
+
<li class="current">
|
57
|
+
<a class="selected" href="index.html">Home</a>
|
58
|
+
</li>
|
59
|
+
</ul>
|
60
|
+
<!--+
|
61
|
+
|end Tabs
|
62
|
+
+-->
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
<div id="main">
|
66
|
+
<div id="publishedStrip">
|
67
|
+
<!--+
|
68
|
+
|start Subtabs
|
69
|
+
+-->
|
70
|
+
<div id="level2tabs"></div>
|
71
|
+
<!--+
|
72
|
+
|end Endtabs
|
73
|
+
+-->
|
74
|
+
<script type="text/javascript"><!--
|
75
|
+
document.write("Last Published: " + document.lastModified);
|
76
|
+
// --></script>
|
77
|
+
</div>
|
78
|
+
<!--+
|
79
|
+
|breadtrail
|
80
|
+
+-->
|
81
|
+
<div class="breadtrail">
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
<!--+
|
86
|
+
|start Menu, mainarea
|
87
|
+
+-->
|
88
|
+
<!--+
|
89
|
+
|start Menu
|
90
|
+
+-->
|
91
|
+
<div id="menu">
|
92
|
+
<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>
|
93
|
+
<div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
|
94
|
+
<div class="menuitem">
|
95
|
+
<a href="index.html" title="ai4r - Artificial Intelligence for Ruby">Index</a>
|
96
|
+
</div>
|
97
|
+
<div class="menuitem">
|
98
|
+
<a href="geneticAlgorithms.html" title="Genetic Algorithms in ruby">Genetic Algorithms</a>
|
99
|
+
</div>
|
100
|
+
<div class="menuitem">
|
101
|
+
<a href="machineLearning.html" title="ID3 Decision Trees in ruby">Machine Learning</a>
|
102
|
+
</div>
|
103
|
+
<div class="menuitem">
|
104
|
+
<a href="neuralNetworks.html" title="Backpropagation Neural Network in ruby">Neural Networks</a>
|
105
|
+
</div>
|
106
|
+
<div class="menupage">
|
107
|
+
<div class="menupagetitle">Downloads</div>
|
108
|
+
</div>
|
109
|
+
<div class="menuitem">
|
110
|
+
<a href="svn.html" title="ai4r Subversion repository">Subversion (svn)</a>
|
111
|
+
</div>
|
112
|
+
<div class="menuitem">
|
113
|
+
<a href="wholesite.pdf">ai4r project PDF</a>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
<div id="credit">
|
117
|
+
<script type="text/javascript">
|
118
|
+
google_ad_client = "pub-2578934938711895";
|
119
|
+
google_ad_slot = "6111091580";
|
120
|
+
google_ad_width = 125;
|
121
|
+
google_ad_height = 125;
|
122
|
+
</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
|
123
|
+
<hr>
|
124
|
+
</div>
|
125
|
+
<div id="roundbottom">
|
126
|
+
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
|
127
|
+
<!--+
|
128
|
+
|alternative credits
|
129
|
+
+-->
|
130
|
+
<div id="credit2"></div>
|
131
|
+
</div>
|
132
|
+
<!--+
|
133
|
+
|end Menu
|
134
|
+
+-->
|
135
|
+
<!--+
|
136
|
+
|start content
|
137
|
+
+-->
|
138
|
+
<div id="content">
|
139
|
+
<div title="Portable Document Format" class="pdflink">
|
140
|
+
<a class="dida" href="downloads.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
|
141
|
+
PDF</a>
|
142
|
+
</div>
|
143
|
+
<h1>Artificial intelligence for ruby :: ai4r :: download page at RubyForge</h1>
|
144
|
+
<div id="minitoc-area">
|
145
|
+
<ul class="minitoc">
|
146
|
+
<li>
|
147
|
+
<a href="#intro">Artificial intelligence for ruby - ai4r - download page at RubyForge</a>
|
148
|
+
</li>
|
149
|
+
</ul>
|
150
|
+
</div>
|
151
|
+
<a name="N10010"></a><a name="intro"></a>
|
152
|
+
<h2 class="boxed">Artificial intelligence for ruby - ai4r - download page at RubyForge</h2>
|
153
|
+
<div class="section">
|
154
|
+
<iframe frameborder="0" height="800px" src="http://rubyforge.org/frs/?group_id=4942" width="100%"></iframe>
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
<!--+
|
158
|
+
|end content
|
159
|
+
+-->
|
160
|
+
<div class="clearboth"> </div>
|
161
|
+
</div>
|
162
|
+
<div id="footer">
|
163
|
+
<!--+
|
164
|
+
|start bottomstrip
|
165
|
+
+-->
|
166
|
+
<div class="lastmodified">
|
167
|
+
<script type="text/javascript"><!--
|
168
|
+
document.write("Last Published: " + document.lastModified);
|
169
|
+
// --></script>
|
170
|
+
</div>
|
171
|
+
<div class="copyright">
|
172
|
+
Copyright ©
|
173
|
+
2007-2008 Sergio Fierens</div>
|
174
|
+
<div class="host">
|
175
|
+
<a href="http://rubyforge.org/projects/ai4r/"><img class="logoImage" alt="" src="images/rubyforge.png"></a>
|
176
|
+
</div>
|
177
|
+
<!--+
|
178
|
+
|end bottomstrip
|
179
|
+
+-->
|
180
|
+
</div>
|
181
|
+
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
|
182
|
+
var pageTracker = _gat._getTracker("UA-3234625-1");
|
183
|
+
pageTracker._initData();
|
184
|
+
pageTracker._trackPageview();
|
185
|
+
</script>
|
186
|
+
</body>
|
187
|
+
</html>
|