ai4r 1.2 → 1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. data/README.rdoc +12 -25
  2. data/examples/decision_trees/id3_example.rb +6 -9
  3. data/examples/decision_trees/results.txt +2 -0
  4. data/examples/genetic_algorithm/genetic_algorithm_example.rb +11 -13
  5. data/examples/neural_network/xor_example.rb +25 -0
  6. data/lib/ai4r.rb +10 -0
  7. data/lib/ai4r/classifiers/classifier.rb +46 -0
  8. data/lib/ai4r/classifiers/id3.rb +27 -58
  9. data/lib/ai4r/classifiers/one_r.rb +19 -58
  10. data/lib/ai4r/classifiers/prism.rb +21 -57
  11. data/lib/ai4r/classifiers/zero_r.rb +16 -48
  12. data/lib/ai4r/clusterers/bisecting_k_means.rb +115 -0
  13. data/lib/ai4r/clusterers/clusterer.rb +55 -0
  14. data/lib/ai4r/clusterers/k_means.rb +164 -0
  15. data/lib/ai4r/data/data_set.rb +250 -0
  16. data/lib/ai4r/genetic_algorithm/genetic_algorithm.rb +19 -19
  17. data/lib/ai4r/neural_network/backpropagation.rb +23 -24
  18. data/site/build/site/en/broken-links.xml +2 -0
  19. data/site/build/site/en/downloads.html +200 -0
  20. data/site/build/site/en/downloads.pdf +151 -0
  21. data/site/build/site/en/forum.html +197 -0
  22. data/site/build/site/en/forum.pdf +151 -0
  23. data/site/build/site/en/geneticAlgorithms.html +591 -0
  24. data/site/build/site/en/geneticAlgorithms.pdf +934 -0
  25. data/site/build/site/en/images/ai4r-logo.png +0 -0
  26. data/site/build/site/en/images/built-with-forrest-button.png +0 -0
  27. data/site/build/site/en/images/c.png +0 -0
  28. data/site/build/site/en/images/c_wbn.png +0 -0
  29. data/site/build/site/en/images/c_wn.png +0 -0
  30. data/site/build/site/en/images/ero.gif +0 -0
  31. data/site/build/site/en/images/europe2.png +0 -0
  32. data/site/build/site/en/images/europe3.png +0 -0
  33. data/site/build/site/en/images/fitness.png +0 -0
  34. data/site/build/site/en/images/genetic_algorithms_example.png +0 -0
  35. data/site/build/site/en/images/instruction_arrow.png +0 -0
  36. data/site/build/site/en/images/jadeferret.png +0 -0
  37. data/site/build/site/en/images/my_email.png +0 -0
  38. data/site/build/site/en/images/neural_network_example.png +0 -0
  39. data/site/build/site/en/images/rubyforge.png +0 -0
  40. data/site/build/site/en/images/s.png +0 -0
  41. data/site/build/site/en/images/s_wbn.png +0 -0
  42. data/site/build/site/en/images/s_wn.png +0 -0
  43. data/site/build/site/en/images/sigmoid.png +0 -0
  44. data/site/build/site/en/images/t.png +0 -0
  45. data/site/build/site/en/images/t_wbn.png +0 -0
  46. data/site/build/site/en/images/t_wn.png +0 -0
  47. data/site/build/site/en/index.html +336 -0
  48. data/site/build/site/en/index.pdf +508 -0
  49. data/site/build/site/en/linkmap.html +263 -0
  50. data/site/build/site/en/linkmap.pdf +94 -0
  51. data/site/build/site/en/locationmap.xml +72 -0
  52. data/site/build/site/en/machineLearning.html +339 -0
  53. data/site/build/site/en/machineLearning.pdf +337 -0
  54. data/site/build/site/en/neuralNetworks.html +484 -0
  55. data/site/build/site/en/neuralNetworks.pdf +604 -0
  56. data/site/build/site/en/skin/CommonMessages_de.xml +23 -0
  57. data/site/build/site/en/skin/CommonMessages_en_US.xml +23 -0
  58. data/site/build/site/en/skin/CommonMessages_es.xml +23 -0
  59. data/site/build/site/en/skin/CommonMessages_fr.xml +23 -0
  60. data/site/build/site/en/skin/basic.css +166 -0
  61. data/site/build/site/en/skin/breadcrumbs-optimized.js +90 -0
  62. data/site/build/site/en/skin/breadcrumbs.js +237 -0
  63. data/site/build/site/en/skin/fontsize.js +166 -0
  64. data/site/build/site/en/skin/getBlank.js +40 -0
  65. data/site/build/site/en/skin/getMenu.js +45 -0
  66. data/site/build/site/en/skin/images/README.txt +1 -0
  67. data/site/build/site/en/skin/images/add.jpg +0 -0
  68. data/site/build/site/en/skin/images/built-with-forrest-button.png +0 -0
  69. data/site/build/site/en/skin/images/chapter.gif +0 -0
  70. data/site/build/site/en/skin/images/chapter_open.gif +0 -0
  71. data/site/build/site/en/skin/images/current.gif +0 -0
  72. data/site/build/site/en/skin/images/error.png +0 -0
  73. data/site/build/site/en/skin/images/external-link.gif +0 -0
  74. data/site/build/site/en/skin/images/fix.jpg +0 -0
  75. data/site/build/site/en/skin/images/forrest-credit-logo.png +0 -0
  76. data/site/build/site/en/skin/images/hack.jpg +0 -0
  77. data/site/build/site/en/skin/images/header_white_line.gif +0 -0
  78. data/site/build/site/en/skin/images/info.png +0 -0
  79. data/site/build/site/en/skin/images/instruction_arrow.png +0 -0
  80. data/site/build/site/en/skin/images/label.gif +0 -0
  81. data/site/build/site/en/skin/images/page.gif +0 -0
  82. data/site/build/site/en/skin/images/pdfdoc.gif +0 -0
  83. data/site/build/site/en/skin/images/poddoc.png +0 -0
  84. data/site/build/site/en/skin/images/printer.gif +0 -0
  85. data/site/build/site/en/skin/images/rc-b-l-15-1body-2menu-3menu.png +0 -0
  86. data/site/build/site/en/skin/images/rc-b-r-15-1body-2menu-3menu.png +0 -0
  87. data/site/build/site/en/skin/images/rc-b-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  88. data/site/build/site/en/skin/images/rc-t-l-5-1header-2searchbox-3searchbox.png +0 -0
  89. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-selected-3tab-selected.png +0 -0
  90. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  91. data/site/build/site/en/skin/images/rc-t-r-15-1body-2menu-3menu.png +0 -0
  92. data/site/build/site/en/skin/images/rc-t-r-5-1header-2searchbox-3searchbox.png +0 -0
  93. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  94. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  95. data/site/build/site/en/skin/images/remove.jpg +0 -0
  96. data/site/build/site/en/skin/images/rss.png +0 -0
  97. data/site/build/site/en/skin/images/spacer.gif +0 -0
  98. data/site/build/site/en/skin/images/success.png +0 -0
  99. data/site/build/site/en/skin/images/txtdoc.png +0 -0
  100. data/site/build/site/en/skin/images/update.jpg +0 -0
  101. data/site/build/site/en/skin/images/valid-html401.png +0 -0
  102. data/site/build/site/en/skin/images/vcss.png +0 -0
  103. data/site/build/site/en/skin/images/warning.png +0 -0
  104. data/site/build/site/en/skin/images/xmldoc.gif +0 -0
  105. data/site/build/site/en/skin/menu.js +48 -0
  106. data/site/build/site/en/skin/note.txt +50 -0
  107. data/site/build/site/en/skin/print.css +54 -0
  108. data/site/build/site/en/skin/profile.css +163 -0
  109. data/site/build/site/en/skin/prototype.js +1257 -0
  110. data/site/build/site/en/skin/screen.css +587 -0
  111. data/site/build/site/en/svn.html +252 -0
  112. data/site/build/site/en/svn.pdf +306 -0
  113. data/site/build/site/en/wholesite.pdf +1915 -0
  114. data/site/build/tmp/brokenlinks.xml +2 -0
  115. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.data +0 -0
  116. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.index +0 -0
  117. data/site/build/tmp/locationmap.xml +14 -14
  118. data/site/build/tmp/output.xmap +23 -23
  119. data/site/build/tmp/pluginlist2fetchbuild.xml +144 -144
  120. data/site/build/tmp/projfilters.properties +41 -41
  121. data/site/build/webapp/WEB-INF/logs/core.log +593 -679
  122. data/site/build/webapp/WEB-INF/logs/error.log +362 -279
  123. data/site/build/webapp/WEB-INF/logs/sitemap.log +368 -1015
  124. data/site/src/documentation/content/xdocs/index.xml +18 -10
  125. data/site/src/documentation/content/xdocs/machineLearning.xml +4 -3
  126. data/site/src/documentation/content/xdocs/site.xml +2 -1
  127. data/site/src/documentation/resources/images/sigmoid.png +0 -0
  128. data/test/classifiers/id3_test.rb +45 -44
  129. data/test/classifiers/one_r_test.rb +19 -17
  130. data/test/classifiers/prism_test.rb +22 -20
  131. data/test/classifiers/zero_r_test.rb +15 -12
  132. data/test/clusterers/bisecting_k_means_test.rb +59 -0
  133. data/test/clusterers/k_means_test.rb +93 -0
  134. data/test/data/data_set_test.rb +92 -0
  135. metadata +252 -128
  136. data/lib/ai4r/classifiers/classifier_helper.rb +0 -54
  137. data/site/src/documentation/content/xdocs/forum.html +0 -9
  138. data/site/src/documentation/resources/images/Thumbs.db +0 -0
  139. data/site/src/documentation/resources/images/sub-dir/Thumbs.db +0 -0
@@ -0,0 +1,250 @@
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 'csv'
11
+ require 'set'
12
+
13
+ module Ai4r
14
+ module Data
15
+ class DataSet
16
+
17
+ attr_reader :data_labels, :data_items
18
+
19
+ # Create a new DataSet. By default, empty.
20
+ # Optionaly, you can provide the initial data items and data labels.
21
+ #
22
+ # e.g. DataSet.new(:data_items => data_items, :data_labels => labels)
23
+ #
24
+ # If you provide data items, but no data labels, the data set will
25
+ # use the default data label values (see set_data_labels)
26
+ def initialize(options = {})
27
+ @data_labels = options[:data_labels] || []
28
+ @data_items = options[:data_items] || []
29
+ set_data_labels(options[:data_labels]) if options[:data_labels]
30
+ set_data_items(options[:data_items]) if options[:data_items]
31
+ end
32
+
33
+ # Retrieve data item(s) by index. You can specify a an index range, too.
34
+ def [](index)
35
+ return @data_items[index]
36
+ end
37
+
38
+ # Load data items from csv file
39
+ def load_data_from_csv(filepath)
40
+ items = []
41
+ CSV::Reader.parse(File.open(filepath, 'r')) do |row|
42
+ items << row
43
+ end
44
+ set_data_items(items)
45
+ end
46
+
47
+ # Load data items from csv file. The first row is used as data labels.
48
+ def load_data_and_labels_from_csv(filepath)
49
+ load_data_from_csv(filepath)
50
+ @data_labels = @data_items.shift
51
+ return self
52
+ end
53
+
54
+ # Set data labels.
55
+ # Data labels must have the following format:
56
+ # [ 'city', 'age_range', 'gender', 'marketing_target' ]
57
+ #
58
+ # If you do not provide labels for you data, the following labels will
59
+ # be created by default:
60
+ # [ 'attribute_1', 'attribute_2', 'attribute_3', 'class_value' ]
61
+ def set_data_labels(labels)
62
+ check_data_labels(labels)
63
+ @data_labels = labels
64
+ return self
65
+ end
66
+
67
+ # Set the data items.
68
+ # M data items with N attributes must have the following
69
+ # format:
70
+ #
71
+ # [ [ATT1_VAL1, ATT2_VAL1, ATT3_VAL1, ... , ATTN_VAL1, CLASS_VAL1],
72
+ # [ATT1_VAL2, ATT2_VAL2, ATT3_VAL2, ... , ATTN_VAL2, CLASS_VAL2],
73
+ # ...
74
+ # [ATTM1_VALM, ATT2_VALM, ATT3_VALM, ... , ATTN_VALM, CLASS_VALM],
75
+ # ]
76
+ #
77
+ # e.g.
78
+ # [ ['New York', '<30', 'M', 'Y'],
79
+ # ['Chicago', '<30', 'M', 'Y'],
80
+ # ['Chicago', '<30', 'F', 'Y'],
81
+ # ['New York', '<30', 'M', 'Y'],
82
+ # ['New York', '<30', 'M', 'Y'],
83
+ # ['Chicago', '[30-50)', 'M', 'Y'],
84
+ # ['New York', '[30-50)', 'F', 'N'],
85
+ # ['Chicago', '[30-50)', 'F', 'Y'],
86
+ # ['New York', '[30-50)', 'F', 'N'],
87
+ # ['Chicago', '[50-80]', 'M', 'N'],
88
+ # ['New York', '[50-80]', 'F', 'N'],
89
+ # ['New York', '[50-80]', 'M', 'N'],
90
+ # ['Chicago', '[50-80]', 'M', 'N'],
91
+ # ['New York', '[50-80]', 'F', 'N'],
92
+ # ['Chicago', '>80', 'F', 'Y']
93
+ # ]
94
+ #
95
+ # This method returns the classifier (self), allowing method chaining.
96
+ def set_data_items(items)
97
+ check_data_items(items)
98
+ @data_labels = default_data_labels(items) if @data_labels.empty?
99
+ @data_items = items
100
+ return self
101
+ end
102
+
103
+ # Returns an array with the domain of each attribute (Set instance
104
+ # containing all possible values)
105
+ # Return example:
106
+ # => [#<Set: {"New York", "Chicago"}>,
107
+ # #<Set: {"<30", "[30-50)", "[50-80]", ">80"}>,
108
+ # #<Set: {"M", "F"}>,
109
+ # #<Set: {"Y", "N"}>]
110
+ def build_domains
111
+ domains = Array.new(num_attributes) { Set.new }
112
+ @data_items.each do |data|
113
+ data.each_index {|attr_index| domains[attr_index] << data[attr_index]}
114
+ end
115
+ return domains
116
+ end
117
+
118
+ # Returns a Set instance containing all possible values for an attribute
119
+ # The parameter can be an attribute label or index (0 based).
120
+ #
121
+ # build_domain("city")
122
+ # => #<Set: {"New York", "Chicago"}>
123
+ #
124
+ # build_domain(2) # In this example, the third attribute is gender
125
+ # => #<Set: {"M", "F"}>
126
+ def build_domain(attr)
127
+ index = get_index(attr)
128
+ domain = Set.new
129
+ @data_items.each do |data|
130
+ domain << data[index]
131
+ end
132
+ return domain
133
+ end
134
+
135
+ # Returns attributes number, including class attribute
136
+ def num_attributes
137
+ return (@data_items.empty?) ? 0 : @data_items.first.size
138
+ end
139
+
140
+ # Returns the index of a given attribute (0-based).
141
+ # For example, if "gender" is the third attribute, then:
142
+ # get_index("gender")
143
+ # => 2
144
+ def get_index(attr)
145
+ return (attr.is_a?(String)) ? @data_labels.index(attr) : attr
146
+ end
147
+
148
+ # Raise an exception if there is no data item.
149
+ def check_not_empty
150
+ if @data_items.empty?
151
+ raise ArgumentError,"Examples data set must not be empty."
152
+ end
153
+ end
154
+
155
+ # Add a data item to the data set
156
+ def << data_item
157
+ if data_item.nil? || !data_item.is_a?(Array) || data_item.empty?
158
+ raise ArgumentError,"Data must not be an non empty array."
159
+ elsif @data_items.empty?
160
+ set_data_items([data_item])
161
+ elsif data_item.length != num_attributes
162
+ raise ArgumentError,"Number of attributes do not match. " +
163
+ "#{data_item.length} attributes provided, " +
164
+ "#{num_attributes} attributes expected."
165
+ else
166
+ @data_items << data_item
167
+ end
168
+ end
169
+
170
+ def get_attribute_mean(attribute)
171
+ index = get_index(attribute)
172
+ mean = 0.0
173
+ @data_items.each { |data_item| mean += data_item[index] }
174
+ mean /= @data_items.length
175
+ return mean
176
+ end
177
+
178
+ def get_attribute_mode(attribute)
179
+ index = get_index(attribute)
180
+ domain = build_domain(attribute)
181
+ count = {}
182
+ domain.each {|value| count[value]=0}
183
+ @data_items.each { |data_item| count[data_item[index]] += 1 }
184
+ max_count = 0
185
+ mode = nil
186
+ count.each_pair do |value, value_count|
187
+ if value_count > max_count
188
+ mode = value
189
+ max_count = value_count
190
+ end
191
+ end
192
+ return mode
193
+ end
194
+
195
+ def get_attribute_mean_or_mode(attribute)
196
+ index = get_index(attribute)
197
+ if @data_items.first[index].is_a?(Numeric)
198
+ return get_attribute_mean(attribute)
199
+ else
200
+ return get_attribute_mode(attribute)
201
+ end
202
+ end
203
+
204
+ def get_mean_or_mode
205
+ mean = []
206
+ num_attributes.times {|i| mean[i] = get_attribute_mean_or_mode(i) }
207
+ return mean
208
+ end
209
+
210
+ protected
211
+ def check_data_items(data_items)
212
+ if !data_items || data_items.empty?
213
+ raise ArgumentError,"Examples data set must not be empty."
214
+ elsif !data_items.first.is_a?(Array)
215
+ raise ArgumentError,"Unkown format for example data."
216
+ end
217
+ attributes_num = data_items.first.length
218
+ data_items.each_index do |index|
219
+ if data_items[index].length != attributes_num
220
+ raise ArgumentError,
221
+ "Quantity of attributes is inconsistent. " +
222
+ "The first item has #{attributes_num} attributes "+
223
+ "and row #{index} has #{data_items[index].length} attributes"
224
+ end
225
+ end
226
+ end
227
+
228
+ def check_data_labels(labels)
229
+ if !@data_items.empty?
230
+ if labels.length != @data_items.first.length
231
+ raise ArgumentError,
232
+ "Number of labels and attributes do not match. " +
233
+ "#{labels.length} labels and " +
234
+ "#{@data_items.first.length} attributes found."
235
+ end
236
+ end
237
+ end
238
+
239
+ def default_data_labels(data_items)
240
+ data_labels = []
241
+ data_items[0][0..-2].each_index do |i|
242
+ data_labels[i] = "attribute_#{i+1}"
243
+ end
244
+ data_labels[data_labels.length]="class_value"
245
+ return data_labels
246
+ end
247
+
248
+ end
249
+ end
250
+ end
@@ -1,14 +1,4 @@
1
1
  #
2
- # The GeneticAlgorithm module implements the GeneticSearch and Chromosome
3
- # classes. The GeneticSearch is a generic class, and can be used to solved
4
- # any kind of problems. The GeneticSearch class performs a stochastic search
5
- # of the solution of a given problem.
6
- #
7
- # The Chromosome is "problem specific". Ai4r built-in Chromosomeclass was
8
- # designed to model the Travelling salesman problem. If you want to solve other
9
- # type of problem, you will have to modify the Chromosome class, by overwriting
10
- # its fitness, reproduce, and mutate functions, to model you specific problem.
11
- #
12
2
  # Author:: Sergio Fierens
13
3
  # License:: MPL 1.1
14
4
  # Project:: ai4r
@@ -19,7 +9,16 @@
19
9
  # Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
20
10
 
21
11
  module Ai4r
22
-
12
+
13
+ # The GeneticAlgorithm module implements the GeneticSearch and Chromosome
14
+ # classes. The GeneticSearch is a generic class, and can be used to solved
15
+ # any kind of problems. The GeneticSearch class performs a stochastic search
16
+ # of the solution of a given problem.
17
+ #
18
+ # The Chromosome is "problem specific". Ai4r built-in Chromosomeclass was
19
+ # designed to model the Travelling salesman problem. If you want to solve other
20
+ # type of problem, you will have to modify the Chromosome class, by overwriting
21
+ # its fitness, reproduce, and mutate functions, to model you specific problem.
23
22
  module GeneticAlgorithm
24
23
 
25
24
  # This class is used to automatically:
@@ -156,10 +155,10 @@ module Ai4r
156
155
 
157
156
  end
158
157
 
159
- # A Chromosome is a representation of an individual solutions for a specific
160
- # problem. You will have to redifine you Chromosome representation for each
158
+ # A Chromosome is a representation of an individual solution for a specific
159
+ # problem. You will have to redifine the Chromosome representation for each
161
160
  # particular problem, along with its fitness, mutate, reproduce, and seed
162
- # functions.
161
+ # methods.
163
162
  class Chromosome
164
163
 
165
164
  attr_accessor :data
@@ -169,7 +168,7 @@ module Ai4r
169
168
  @data = data
170
169
  end
171
170
 
172
- # The fitness function quantifies the optimality of a solution
171
+ # The fitness method quantifies the optimality of a solution
173
172
  # (that is, a chromosome) in a genetic algorithm so that that particular
174
173
  # chromosome may be ranked against all the other chromosomes.
175
174
  #
@@ -188,7 +187,7 @@ module Ai4r
188
187
  return @fitness
189
188
  end
190
189
 
191
- # mutation is a function used to maintain genetic diversity from one
190
+ # mutation method is used to maintain genetic diversity from one
192
191
  # generation of a population of chromosomes to the next. It is analogous
193
192
  # to biological mutation.
194
193
  #
@@ -214,8 +213,8 @@ module Ai4r
214
213
  end
215
214
  end
216
215
 
217
- # Reproduction is used to vary the programming of a chromosome or
218
- # chromosomes from one generation to the next. There are several ways to
216
+ # Reproduction method is used to combine two chromosomes (solutions) into
217
+ # a single new chromosome. There are several ways to
219
218
  # combine two chromosomes: One-point crossover, Two-point crossover,
220
219
  # "Cut and splice", edge recombination, and more.
221
220
  #
@@ -249,7 +248,8 @@ module Ai4r
249
248
 
250
249
  # Initializes an individual solution (chromosome) for the initial
251
250
  # population. Usually the chromosome is generated randomly, but you can
252
- # use some problem domain knowledge, to generate better initial solutions.
251
+ # use some problem domain knowledge, to generate a
252
+ # (probably) better initial solution.
253
253
  def self.seed
254
254
  data_size = @@costs[0].length
255
255
  available = []
@@ -1,26 +1,3 @@
1
- # The utility of artificial neural network
2
- # models lies in the fact that they can be used
3
- # to infer a function from observations.
4
- # This is particularly useful in applications
5
- # where the complexity of the data or task makes the
6
- # design of such a function by hand impractical.
7
- # Neural Networks are being used in many businesses and applications. Their
8
- # ability to learn by example makes them attractive in environments where
9
- # the business rules are either not well defined or are hard to enumerate and
10
- # define. Many people believe that Neural Networks can only solve toy problems.
11
- # Give them a try, and let you decide if they are good enough to solve your
12
- # needs.
13
- #
14
- # In this module you will find an implementation of neural networks
15
- # using the Backpropagation is a supervised learning technique (described
16
- # by Paul Werbos in 1974, and further developed by David E.
17
- # Rumelhart, Geoffrey E. Hinton and Ronald J. Williams in 1986)
18
- #
19
- # More about neural networks and backpropagation:
20
- #
21
- # * http://en.wikipedia.org/wiki/Backpropagation
22
- # * http://en.wikipedia.org/wiki/Neural_networks
23
- #
24
1
  # Author:: Sergio Fierens
25
2
  # License:: MPL 1.1
26
3
  # Project:: ai4r
@@ -36,6 +13,28 @@
36
13
 
37
14
  module Ai4r
38
15
 
16
+ # The utility of artificial neural network
17
+ # models lies in the fact that they can be used
18
+ # to infer a function from observations.
19
+ # This is particularly useful in applications
20
+ # where the complexity of the data or task makes the
21
+ # design of such a function by hand impractical.
22
+ # Neural Networks are being used in many businesses and applications. Their
23
+ # ability to learn by example makes them attractive in environments where
24
+ # the business rules are either not well defined or are hard to enumerate and
25
+ # define. Many people believe that Neural Networks can only solve toy problems.
26
+ # Give them a try, and let you decide if they are good enough to solve your
27
+ # needs.
28
+ #
29
+ # In this module you will find an implementation of neural networks
30
+ # using the Backpropagation is a supervised learning technique (described
31
+ # by Paul Werbos in 1974, and further developed by David E.
32
+ # Rumelhart, Geoffrey E. Hinton and Ronald J. Williams in 1986)
33
+ #
34
+ # More about neural networks and backpropagation:
35
+ #
36
+ # * http://en.wikipedia.org/wiki/Backpropagation
37
+ # * http://en.wikipedia.org/wiki/Neural_networks
39
38
  module NeuralNetwork
40
39
 
41
40
  # = Introduction
@@ -48,7 +47,7 @@ module Ai4r
48
47
  # = How to use it
49
48
  #
50
49
  # # Create the network
51
- # net = Backpropagation.new([4, 3, 2]) # 4 inputs
50
+ # net = Ai4r::NeuralNetwork::Backpropagation.new([4, 3, 2]) # 4 inputs
52
51
  # # 1 hidden layer with 3 neurons,
53
52
  # # 2 outputs
54
53
  # # Train the network
@@ -0,0 +1,2 @@
1
+ <broken-links>
2
+ </broken-links>
@@ -0,0 +1,200 @@
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
+ <div class="grouplogo">
28
+ <a href="http://www.jadeferret.com"><img class="logoImage" alt="Jade Ferret" src="images/jadeferret.png" title="Jade Ferret"></a>
29
+ </div>
30
+ <!--+
31
+ |end group logo
32
+ +-->
33
+ <!--+
34
+ |start Project Logo
35
+ +-->
36
+ <div class="projectlogo">
37
+ <a href="http://ai4r.rubyforge.org/"><img class="logoImage" alt="ai4r" src="images/ai4r-logo.png" title="AI4R - Artificial Intelligence for Ruby"></a>
38
+ </div>
39
+ <!--+
40
+ |end Project Logo
41
+ +-->
42
+ <!--+
43
+ |start Search
44
+ +-->
45
+ <div class="searchbox">
46
+ <div class="roundtopsmall">
47
+ <form target="_top" action="http://www.google.com/custom" method="get">
48
+ <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">
49
+ </form>
50
+ </div>
51
+ </div>
52
+ <!--+
53
+ |end search
54
+ +-->
55
+ <!--+
56
+ |start Tabs
57
+ +-->
58
+ <ul id="tabs">
59
+ <li class="current">
60
+ <a class="selected" href="index.html">Home</a>
61
+ </li>
62
+ </ul>
63
+ <!--+
64
+ |end Tabs
65
+ +-->
66
+ </div>
67
+ </div>
68
+ <div id="main">
69
+ <div id="publishedStrip">
70
+ <!--+
71
+ |start Subtabs
72
+ +-->
73
+ <div id="level2tabs"></div>
74
+ <!--+
75
+ |end Endtabs
76
+ +-->
77
+ <script type="text/javascript"><!--
78
+ document.write("Last Published: " + document.lastModified);
79
+ // --></script>
80
+ </div>
81
+ <!--+
82
+ |breadtrail
83
+ +-->
84
+ <div class="breadtrail">
85
+
86
+ &nbsp;
87
+ </div>
88
+ <!--+
89
+ |start Menu, mainarea
90
+ +-->
91
+ <!--+
92
+ |start Menu
93
+ +-->
94
+ <div id="menu">
95
+ <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>
96
+ <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
97
+ <div class="menuitem">
98
+ <a href="index.html" title="ai4r - Artificial Intelligence for Ruby">Index</a>
99
+ </div>
100
+ <div onclick="SwitchMenu('menu_1.1.2', 'skin/')" id="menu_1.1.2Title" class="menutitle">Practical Examples</div>
101
+ <div id="menu_1.1.2" class="menuitemgroup">
102
+ <div class="menuitem">
103
+ <a href="geneticAlgorithms.html" title="Genetic Algorithms in ruby">Genetic Algorithms</a>
104
+ </div>
105
+ <div class="menuitem">
106
+ <a href="machineLearning.html" title="ID3 Decision Trees in ruby">Machine Learning</a>
107
+ </div>
108
+ <div class="menuitem">
109
+ <a href="neuralNetworks.html" title="Backpropagation Neural Network in ruby">Neural Networks</a>
110
+ </div>
111
+ </div>
112
+ <div class="menupage">
113
+ <div class="menupagetitle">Downloads</div>
114
+ </div>
115
+ <div class="menuitem">
116
+ <a href="http://forum.jadeferret.com/viewforum.php?f=3" title="Ai4r Forum">Forum</a>
117
+ </div>
118
+ <div class="menuitem">
119
+ <a href="http://ai4r.rubyforge.org/rdoc/index.html" title="Ai4 RDoc docs">API doc (Rdoc)</a>
120
+ </div>
121
+ <div class="menuitem">
122
+ <a href="svn.html" title="ai4r Subversion repository">Source Code repository</a>
123
+ </div>
124
+ <div class="menuitem">
125
+ <a href="wholesite.pdf">ai4r project PDF</a>
126
+ </div>
127
+ </div>
128
+ <div id="credit">
129
+ <script type="text/javascript">
130
+ google_ad_client = "pub-2578934938711895";
131
+ google_ad_slot = "6111091580";
132
+ google_ad_width = 125;
133
+ google_ad_height = 125;
134
+ </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
135
+ <hr>
136
+ </div>
137
+ <div id="roundbottom">
138
+ <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
139
+ <!--+
140
+ |alternative credits
141
+ +-->
142
+ <div id="credit2"></div>
143
+ </div>
144
+ <!--+
145
+ |end Menu
146
+ +-->
147
+ <!--+
148
+ |start content
149
+ +-->
150
+ <div id="content">
151
+ <div title="Portable Document Format" class="pdflink">
152
+ <a class="dida" href="downloads.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
153
+ PDF</a>
154
+ </div>
155
+ <h1>Artificial intelligence for ruby :: ai4r :: download page at RubyForge</h1>
156
+ <div id="minitoc-area">
157
+ <ul class="minitoc">
158
+ <li>
159
+ <a href="#intro">Artificial intelligence for ruby - ai4r - download page at RubyForge</a>
160
+ </li>
161
+ </ul>
162
+ </div>
163
+ <a name="N10010"></a><a name="intro"></a>
164
+ <h2 class="boxed">Artificial intelligence for ruby - ai4r - download page at RubyForge</h2>
165
+ <div class="section">
166
+ <iframe frameborder="0" height="800px" src="http://rubyforge.org/frs/?group_id=4942" width="100%"></iframe>
167
+ </div>
168
+ </div>
169
+ <!--+
170
+ |end content
171
+ +-->
172
+ <div class="clearboth">&nbsp;</div>
173
+ </div>
174
+ <div id="footer">
175
+ <!--+
176
+ |start bottomstrip
177
+ +-->
178
+ <div class="lastmodified">
179
+ <script type="text/javascript"><!--
180
+ document.write("Last Published: " + document.lastModified);
181
+ // --></script>
182
+ </div>
183
+ <div class="copyright">
184
+ Copyright &copy;
185
+ 2007-2009 <a href="http://www.jadeferret.com/">Sergio Fierens, Jade Ferret</a>
186
+ </div>
187
+ <div class="host">
188
+ <a href="http://rubyforge.org/projects/ai4r/"><img class="logoImage" alt="" src="images/rubyforge.png"></a>
189
+ </div>
190
+ <!--+
191
+ |end bottomstrip
192
+ +-->
193
+ </div>
194
+ <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
195
+ var pageTracker = _gat._getTracker("UA-3234625-1");
196
+ pageTracker._initData();
197
+ pageTracker._trackPageview();
198
+ </script>
199
+ </body>
200
+ </html>