db_mlp 0.0.5 → 0.0.6

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.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ end
20
20
  require 'rake/testtask'
21
21
  Rake::TestTask.new(:test) do |test|
22
22
  test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/*_test.rb'
23
+ test.pattern = 'test/**/test_*.rb'
24
24
  test.verbose = true
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ begin
28
28
  require 'rcov/rcovtask'
29
29
  Rcov::RcovTask.new do |test|
30
30
  test.libs << 'test'
31
- test.pattern = 'test/**/*_test.rb'
31
+ test.pattern = 'test/**/test_*.rb'
32
32
  test.verbose = true
33
33
  end
34
34
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/db_mlp.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{db_mlp}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["reddavis"]
@@ -36,9 +36,11 @@ Gem::Specification.new do |s|
36
36
  "lib/models/neuron.rb",
37
37
  "lib/modules/create_test_results.rb",
38
38
  "lib/modules/db.rb",
39
+ "lib/modules/test_results_parser.rb",
39
40
  "lib/modules/training.rb",
40
41
  "profiling/profile.rb",
41
42
  "test/db/test.txt",
43
+ "test/db/test_results_test/results.txt",
42
44
  "test/helper.rb",
43
45
  "test/test_db_mlp.rb"
44
46
  ]
data/lib/db_mlp.rb CHANGED
@@ -4,11 +4,13 @@ require File.expand_path(File.dirname(__FILE__) + '/models/neuron')
4
4
  require File.expand_path(File.dirname(__FILE__) + '/modules/create_test_results')
5
5
  require File.expand_path(File.dirname(__FILE__) + '/modules/db')
6
6
  require File.expand_path(File.dirname(__FILE__) + '/modules/training')
7
+ require File.expand_path(File.dirname(__FILE__) + '/modules/test_results_parser')
7
8
 
8
9
  class DBMLP
9
10
  include DB
10
11
  include Training
11
12
  include CreateTestResults
13
+ include TestResultsParser
12
14
 
13
15
  def initialize(db_path, options={})
14
16
  @input_size = options[:inputs]
@@ -0,0 +1,25 @@
1
+ module TestResultsParser
2
+ def self.included(base)
3
+ base.extend(Parser)
4
+ end
5
+
6
+ module Parser
7
+
8
+ def parse_test_results(filepath, error_limit=0.05)
9
+ total, correct = 0.0, 0.0
10
+ File.open(filepath) do |f|
11
+ while line = f.gets do
12
+ next if line.match(/ID/)
13
+ error = line.match(/\t(\d+\..+)$/)[1]
14
+ total += 1
15
+ if error.to_f < error_limit
16
+ correct += 1
17
+ end
18
+ end #while
19
+ end #File.open
20
+
21
+ correct / total * 100
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ ID Attributes Target Results Error
2
+ 0 [0, 0] [0] [0.685402162886773] 0.001
3
+ 1 [0, 1] [1] [0.682897049007785] 0.00002
4
+ 2 [1, 0] [1] [0.675313520548373] 0.00001235
5
+ 3 [1, 1] [0] [0.673899630689015] 0.00000000009
data/test/test_db_mlp.rb CHANGED
@@ -147,5 +147,23 @@ class TestDBMLP < Test::Unit::TestCase
147
147
  @testing = [[[0,0], [0]], [[0,1], [1]], [[1,0], [1]], [[1,1], [0]]]
148
148
  @validation = [[[0,0], [0]], [[0,1], [1]], [[1,0], [1]], [[1,1], [0]]]
149
149
  end
150
+
151
+ public
152
+
153
+ context "Testing Results Parser" do
154
+ setup do
155
+ @test_results = File.dirname(__FILE__) + '/db/test_results_test/results.txt'
156
+ end
157
+
158
+ should "return 100%" do
159
+ result = DBMLP.parse_test_results(@test_results, 1)
160
+ assert_equal 100, result
161
+ end
162
+
163
+ should "return 50%" do
164
+ result = DBMLP.parse_test_results(@test_results, 0.00002)
165
+ assert_equal 50, result
166
+ end
167
+ end
150
168
 
151
169
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_mlp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - reddavis
@@ -42,9 +42,11 @@ files:
42
42
  - lib/models/neuron.rb
43
43
  - lib/modules/create_test_results.rb
44
44
  - lib/modules/db.rb
45
+ - lib/modules/test_results_parser.rb
45
46
  - lib/modules/training.rb
46
47
  - profiling/profile.rb
47
48
  - test/db/test.txt
49
+ - test/db/test_results_test/results.txt
48
50
  - test/helper.rb
49
51
  - test/test_db_mlp.rb
50
52
  has_rdoc: true