ai4r 1.4 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +24 -3
- data/examples/decision_trees/id3_example.rb +1 -1
- data/examples/genetic_algorithm/genetic_algorithm_example.rb +1 -1
- data/lib/ai4r.rb +11 -0
- data/lib/ai4r/classifiers/classifier.rb +2 -0
- data/lib/ai4r/classifiers/id3.rb +3 -2
- data/lib/ai4r/classifiers/multilayer_perceptron.rb +135 -0
- data/lib/ai4r/classifiers/one_r.rb +2 -1
- data/lib/ai4r/classifiers/prism.rb +2 -1
- data/lib/ai4r/classifiers/zero_r.rb +2 -1
- data/lib/ai4r/clusterers/average_linkage.rb +60 -0
- data/lib/ai4r/clusterers/bisecting_k_means.rb +17 -39
- data/lib/ai4r/clusterers/clusterer.rb +25 -0
- data/lib/ai4r/clusterers/complete_linkage.rb +62 -0
- data/lib/ai4r/clusterers/k_means.rb +18 -25
- data/lib/ai4r/clusterers/single_linkage.rb +179 -0
- data/lib/ai4r/data/data_set.rb +33 -41
- data/lib/ai4r/data/proximity.rb +82 -0
- data/lib/ai4r/data/statistics.rb +77 -0
- data/lib/ai4r/experiment/classifier_evaluator.rb +95 -0
- data/lib/ai4r/genetic_algorithm/genetic_algorithm.rb +2 -4
- data/site/build/site/en/build/tmp/build-info.xml +5 -0
- data/site/build/site/en/build/tmp/plugins-1.xml +212 -0
- data/site/build/site/en/build/tmp/plugins-2.xml +252 -0
- data/site/build/site/en/build/tmp/projfilters.properties +41 -0
- data/site/build/site/en/downloads.html +1 -1
- data/site/build/site/en/geneticAlgorithms.html +1 -1
- data/site/build/site/en/index.html +44 -7
- data/site/build/site/en/index.pdf +278 -155
- data/site/build/site/en/linkmap.html +2 -2
- data/site/build/site/en/linkmap.pdf +12 -12
- data/site/build/site/en/machineLearning.html +1 -1
- data/site/build/site/en/neuralNetworks.html +1 -1
- data/site/build/site/en/sourceCode.html +244 -0
- data/site/build/site/en/sourceCode.pdf +278 -0
- data/site/build/site/en/svn.html +34 -42
- data/site/build/site/en/svn.pdf +86 -114
- 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/projfilters.properties +1 -1
- data/site/build/webapp/WEB-INF/logs/core.log +628 -629
- data/site/build/webapp/WEB-INF/logs/error.log +213 -213
- data/site/src/documentation/content/xdocs/index.xml +20 -1
- data/site/src/documentation/content/xdocs/site.xml +1 -1
- data/site/src/documentation/content/xdocs/sourceCode.xml +43 -0
- data/site/src/documentation/resources/images/sigmoid.png +0 -0
- data/test/classifiers/id3_test.rb +0 -1
- data/test/classifiers/multilayer_perceptron_test.rb +79 -0
- data/test/classifiers/one_r_test.rb +0 -2
- data/test/classifiers/prism_test.rb +0 -2
- data/test/classifiers/zero_r_test.rb +0 -2
- data/test/clusterers/average_linkage_test.rb +45 -0
- data/test/clusterers/bisecting_k_means_test.rb +0 -2
- data/test/clusterers/complete_linkage_test.rb +45 -0
- data/test/clusterers/k_means_test.rb +0 -2
- data/test/clusterers/single_linkage_test.rb +113 -0
- data/test/data/data_set_test.rb +3 -15
- data/test/data/proximity_test.rb +71 -0
- data/test/data/statistics_test.rb +65 -0
- data/test/experiment/classifier_evaluator_test.rb +76 -0
- metadata +27 -6
- data/site/src/documentation/content/xdocs/svn.xml +0 -41
@@ -0,0 +1,65 @@
|
|
1
|
+
# Author:: Sergio Fierens
|
2
|
+
# License:: MPL 1.1
|
3
|
+
# Project:: ai4r
|
4
|
+
# Url:: http://ai4r.rubyforge.org/
|
5
|
+
#
|
6
|
+
# You can redistribute it and/or modify it under the terms of
|
7
|
+
# the Mozilla Public License version 1.1 as published by the
|
8
|
+
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require File.dirname(__FILE__) + '/../../lib/ai4r/data/statistics'
|
12
|
+
|
13
|
+
module Ai4r
|
14
|
+
module Data
|
15
|
+
class StatisticsTest < Test::Unit::TestCase
|
16
|
+
|
17
|
+
DELTA = 0.00001
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@data_set = DataSet.new.
|
21
|
+
parse_csv "#{File.dirname(__FILE__)}/statistics_data_set.csv"
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_mean
|
25
|
+
assert_equal 2, Statistics.mean(@data_set, 1)
|
26
|
+
assert_equal 2.502, Statistics.mean(@data_set, 0)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_variance
|
30
|
+
assert_equal 0, Statistics.variance(@data_set, 1)
|
31
|
+
assert_in_delta 4.47302, Statistics.variance(@data_set, 0), DELTA
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_standard_deviation
|
35
|
+
assert_equal 0, Statistics.standard_deviation(@data_set, 1)
|
36
|
+
assert_in_delta 2.11495, Statistics.standard_deviation(@data_set, 0), DELTA
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_mode
|
40
|
+
items = [ [ "New York", 25, "Y"],
|
41
|
+
[ "New York", 55, "Y"],
|
42
|
+
[ "Chicago", 23, "Y"],
|
43
|
+
[ "Boston", 23, "N"],
|
44
|
+
[ "Chicago", 12, "N"],
|
45
|
+
[ "Chicago", 87, "Y"] ]
|
46
|
+
set = DataSet.new.set_data_items(items)
|
47
|
+
assert_equal "Chicago", Statistics.mode(set,0)
|
48
|
+
assert_equal 23, Statistics.mode(set,1)
|
49
|
+
assert_equal "Y", Statistics.mode(set,2)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_min
|
53
|
+
assert_equal 2, Statistics.min(@data_set, 1)
|
54
|
+
assert_equal 1, Statistics.min(@data_set, 0)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_max
|
58
|
+
assert_equal 2, Statistics.max(@data_set, 1)
|
59
|
+
assert_equal 6, Statistics.max(@data_set, 0)
|
60
|
+
assert_equal 3.7, Statistics.max(@data_set, 2)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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 'test/unit'
|
11
|
+
require File.dirname(__FILE__) + '/../../lib/ai4r/experiment/classifier_evaluator'
|
12
|
+
require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/classifier'
|
13
|
+
|
14
|
+
class MockClassifier < Ai4r::Classifiers::Classifier
|
15
|
+
|
16
|
+
attr_accessor :built
|
17
|
+
|
18
|
+
def initialize(class_value)
|
19
|
+
@built = false
|
20
|
+
@class_value = class_value
|
21
|
+
end
|
22
|
+
|
23
|
+
def build(data_set)
|
24
|
+
@built = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def eval(data)
|
28
|
+
@class_value
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
module Ai4r
|
34
|
+
module Experiment
|
35
|
+
class ClassifierEvaluatorTest < Test::Unit::TestCase
|
36
|
+
|
37
|
+
def test_add_classifier
|
38
|
+
evaluator = ClassifierEvaluator.new
|
39
|
+
evaluator << MockClassifier.new(nil) << MockClassifier.new(nil)
|
40
|
+
evaluator.add_classifier(MockClassifier.new(nil)).
|
41
|
+
add_classifier(MockClassifier.new(nil)).
|
42
|
+
add_classifier(MockClassifier.new(nil))
|
43
|
+
assert_equal 5, evaluator.classifiers.length
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_build
|
47
|
+
evaluator = ClassifierEvaluator.new
|
48
|
+
5.times { evaluator << MockClassifier.new(nil) }
|
49
|
+
evaluator.classifiers.each {|c| assert !c.built}
|
50
|
+
evaluator.build(Ai4r::Data::DataSet.new)
|
51
|
+
evaluator.classifiers.each {|c| assert c.built}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_eval
|
55
|
+
evaluator = ClassifierEvaluator.new
|
56
|
+
5.times { |x| evaluator << MockClassifier.new(x) }
|
57
|
+
assert_equal [0, 1, 2, 3, 4], evaluator.eval([])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_test
|
61
|
+
evaluator = ClassifierEvaluator.new
|
62
|
+
5.times { |x| evaluator << MockClassifier.new(x) }
|
63
|
+
input = Ai4r::Data::DataSet.new :data_items =>
|
64
|
+
[[0],[0],[0],[1],[2],[3]]
|
65
|
+
output = evaluator.test input
|
66
|
+
assert_equal 5, output.data_items.length # 5 classifiers, 5 result rows
|
67
|
+
output.data_items.each { |result| assert result[1]>=0 && result[1]<1} # eval time
|
68
|
+
assert_equal 3, output.data_items.first[2] # 3 errors for the 1st classifier
|
69
|
+
assert_equal 0.5, output.data_items.first[3] # succes rate
|
70
|
+
assert_equal 6, output.data_items.last[2] # 6 errors for the last classifier
|
71
|
+
assert_equal 0, output.data_items.last[3] # succes rate
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ai4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.5"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Fierens
|
@@ -9,7 +9,7 @@ autorequire: ai4r
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-01 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -38,12 +38,18 @@ files:
|
|
38
38
|
- lib/ai4r.rb
|
39
39
|
- lib/ai4r
|
40
40
|
- lib/ai4r/clusterers
|
41
|
+
- lib/ai4r/clusterers/average_linkage.rb
|
42
|
+
- lib/ai4r/clusterers/complete_linkage.rb
|
41
43
|
- lib/ai4r/clusterers/bisecting_k_means.rb
|
44
|
+
- lib/ai4r/clusterers/single_linkage.rb
|
42
45
|
- lib/ai4r/clusterers/k_means.rb
|
43
46
|
- lib/ai4r/clusterers/clusterer.rb
|
47
|
+
- lib/ai4r/experiment
|
48
|
+
- lib/ai4r/experiment/classifier_evaluator.rb
|
44
49
|
- lib/ai4r/neural_network
|
45
50
|
- lib/ai4r/neural_network/backpropagation.rb
|
46
51
|
- lib/ai4r/classifiers
|
52
|
+
- lib/ai4r/classifiers/multilayer_perceptron.rb
|
47
53
|
- lib/ai4r/classifiers/prism.rb
|
48
54
|
- lib/ai4r/classifiers/one_r.rb
|
49
55
|
- lib/ai4r/classifiers/zero_r.rb
|
@@ -53,7 +59,9 @@ files:
|
|
53
59
|
- lib/ai4r/genetic_algorithm/genetic_algorithm.rb
|
54
60
|
- lib/ai4r/data
|
55
61
|
- lib/ai4r/data/parameterizable.rb
|
62
|
+
- lib/ai4r/data/statistics.rb
|
56
63
|
- lib/ai4r/data/data_set.rb
|
64
|
+
- lib/ai4r/data/proximity.rb
|
57
65
|
- site/build
|
58
66
|
- site/build/webapp
|
59
67
|
- site/build/webapp/conf
|
@@ -71,13 +79,21 @@ files:
|
|
71
79
|
- site/build/webapp/WEB-INF/logs/debug.log
|
72
80
|
- site/build/site
|
73
81
|
- site/build/site/en
|
82
|
+
- site/build/site/en/sourceCode.html
|
74
83
|
- site/build/site/en/svn.pdf
|
84
|
+
- site/build/site/en/sourceCode.pdf
|
75
85
|
- site/build/site/en/linkmap.pdf
|
76
86
|
- site/build/site/en/geneticAlgorithms.html
|
77
87
|
- site/build/site/en/neuralNetworks.pdf
|
78
88
|
- site/build/site/en/neuralNetworks.html
|
79
89
|
- site/build/site/en/machineLearning.html
|
80
90
|
- site/build/site/en/index.html
|
91
|
+
- site/build/site/en/build
|
92
|
+
- site/build/site/en/build/tmp
|
93
|
+
- site/build/site/en/build/tmp/plugins-2.xml
|
94
|
+
- site/build/site/en/build/tmp/projfilters.properties
|
95
|
+
- site/build/site/en/build/tmp/build-info.xml
|
96
|
+
- site/build/site/en/build/tmp/plugins-1.xml
|
81
97
|
- site/build/site/en/machineLearning.pdf
|
82
98
|
- site/build/site/en/locationmap.xml
|
83
99
|
- site/build/site/en/downloads.html
|
@@ -190,12 +206,10 @@ files:
|
|
190
206
|
- site/forrest.properties.dispatcher.properties
|
191
207
|
- site/src
|
192
208
|
- site/src/documentation
|
193
|
-
- site/src/documentation/conf
|
194
209
|
- site/src/documentation/sitemap.xmap
|
195
210
|
- site/src/documentation/resources
|
196
211
|
- site/src/documentation/resources/stylesheets
|
197
212
|
- site/src/documentation/resources/stylesheets/hello2document.xsl
|
198
|
-
- site/src/documentation/resources/themes
|
199
213
|
- site/src/documentation/resources/schema
|
200
214
|
- site/src/documentation/resources/schema/symbols-project-v10.ent
|
201
215
|
- site/src/documentation/resources/schema/catalog.xcat
|
@@ -232,13 +246,13 @@ files:
|
|
232
246
|
- site/src/documentation/README.txt
|
233
247
|
- site/src/documentation/content
|
234
248
|
- site/src/documentation/content/xdocs
|
249
|
+
- site/src/documentation/content/xdocs/sourceCode.xml
|
235
250
|
- site/src/documentation/content/xdocs/index.xml
|
236
251
|
- site/src/documentation/content/xdocs/machineLearning.xml
|
237
252
|
- site/src/documentation/content/xdocs/downloads.html
|
238
253
|
- site/src/documentation/content/xdocs/site.xml
|
239
254
|
- site/src/documentation/content/xdocs/geneticAlgorithms.xml
|
240
255
|
- site/src/documentation/content/xdocs/neuralNetworks.xml
|
241
|
-
- site/src/documentation/content/xdocs/svn.xml
|
242
256
|
- site/src/documentation/content/xdocs/tabs.xml
|
243
257
|
- site/src/documentation/content/locationmap.xml
|
244
258
|
- site/src/documentation/translations
|
@@ -289,18 +303,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
303
|
requirements: []
|
290
304
|
|
291
305
|
rubyforge_project: ai4r
|
292
|
-
rubygems_version: 1.
|
306
|
+
rubygems_version: 1.3.1
|
293
307
|
signing_key:
|
294
308
|
specification_version: 2
|
295
309
|
summary: Ruby implementations of algorithms covering several Artificial intelligence fields, including Genetic algorithms, Neural Networks, machine learning, and clustering.
|
296
310
|
test_files:
|
311
|
+
- test/clusterers/single_linkage_test.rb
|
312
|
+
- test/clusterers/average_linkage_test.rb
|
313
|
+
- test/clusterers/complete_linkage_test.rb
|
297
314
|
- test/clusterers/k_means_test.rb
|
298
315
|
- test/clusterers/bisecting_k_means_test.rb
|
316
|
+
- test/experiment/classifier_evaluator_test.rb
|
299
317
|
- test/neural_network/backpropagation_test.rb
|
300
318
|
- test/classifiers/zero_r_test.rb
|
319
|
+
- test/classifiers/multilayer_perceptron_test.rb
|
301
320
|
- test/classifiers/prism_test.rb
|
302
321
|
- test/classifiers/one_r_test.rb
|
303
322
|
- test/classifiers/id3_test.rb
|
304
323
|
- test/genetic_algorithm/genetic_algorithm_test.rb
|
305
324
|
- test/genetic_algorithm/chromosome_test.rb
|
325
|
+
- test/data/statistics_test.rb
|
326
|
+
- test/data/proximity_test.rb
|
306
327
|
- test/data/data_set_test.rb
|
@@ -1,41 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
|
3
|
-
<document>
|
4
|
-
<header>
|
5
|
-
<title>Subversion repository for ai4r (Artificial Intelligence for Ruby)</title>
|
6
|
-
</header>
|
7
|
-
<body>
|
8
|
-
<section id="Anonymous">
|
9
|
-
<title>Anonymous Subversion Access</title>
|
10
|
-
<p>This project's SVN repository can be checked out through anonymous access with the following command(s).</p>
|
11
|
-
<ul>
|
12
|
-
<li>svn checkout http://ai4r.rubyforge.org/svn/trunk</li>
|
13
|
-
<li>svn checkout svn://rubyforge.org/var/svn/ai4r/trunk</li>
|
14
|
-
</ul>
|
15
|
-
</section>
|
16
|
-
|
17
|
-
<section id="Browse">
|
18
|
-
<title>Browse latest files</title>
|
19
|
-
<p>You can see the latest ai4r code directly in your browser: <a href="http://ai4r.rubyforge.org/svn/">http://ai4r.rubyforge.org/svn/</a>
|
20
|
-
</p>
|
21
|
-
<warning>The latest code in http://ai4r.rubyforge.org/svn/trunk will probably be a work in progess. If you
|
22
|
-
want something that works, please download the releases.</warning>
|
23
|
-
</section>
|
24
|
-
|
25
|
-
<section id="moreinfor">
|
26
|
-
<title>More info on Subversion (svn)</title>
|
27
|
-
<p>If you need help about using Subversion (svn), the (IMO) best documentation is available <a href="http://svnbook.red-bean.com/">here</a>.</p>
|
28
|
-
<p>If you work in SCM, you may find <a href="http://scm.jadeferret.com">Jade Ferret’s SCM initiative</a>
|
29
|
-
intresting.</p>
|
30
|
-
</section>
|
31
|
-
|
32
|
-
<section id="softsizo_report">
|
33
|
-
<title>Source code evolution</title>
|
34
|
-
<p><a href="http://softsizo.jadeferret.com">Soft Sizo</a> is a report generation tool that extends the concept
|
35
|
-
of Lines Of Code (LOC) metrics, using changes information stored in a Subversion repository.</p>
|
36
|
-
<p>You can access <a href="http://softsizo.jadeferret.com/examples/ai4r/index.html">AI4R Soft Sizo report</a>
|
37
|
-
for some AI4R source code evolution metrics.
|
38
|
-
</p>
|
39
|
-
</section>
|
40
|
-
</body>
|
41
|
-
</document>
|