bors 0.0.0 → 0.0.1
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/Gemfile +1 -17
- data/Gemfile.lock +2 -24
- data/README.md +108 -4
- data/VERSION +1 -1
- data/bors.gemspec +19 -25
- data/lib/bors/command_line.rb +39 -0
- data/lib/bors/example/feature.rb +2 -2
- data/lib/bors/example.rb +30 -24
- data/lib/bors/exceptions.rb +1 -1
- data/lib/bors/math.rb +13 -0
- data/lib/bors/result/samples.rb +52 -0
- data/lib/bors/result/settings.rb +48 -0
- data/lib/bors/result/statistics.rb +51 -0
- data/lib/bors/result.rb +25 -0
- data/lib/bors.rb +37 -38
- data/spec/bors/example.rb +5 -1
- data/spec/bors/result/samples.rb +17 -0
- data/spec/bors/result/settings.rb +31 -0
- data/spec/bors/result/statistics.rb +28 -0
- data/spec/bors/result.rb +32 -0
- data/spec/bors.rb +99 -48
- data/spec/fixtures/examples.txt +3 -0
- data/spec/fixtures/result.txt +34 -0
- data/spec/runner.rb +6 -1
- data/spec/tutorial.rb +25 -0
- metadata +21 -92
- data/lib/bors/maths.rb +0 -9
- data/lib/bors/model.rb +0 -82
- data/lib/bors/prediction/result.rb +0 -19
- data/lib/bors/prediction.rb +0 -17
data/lib/bors/model.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
class Bors
|
2
|
-
class Model
|
3
|
-
|
4
|
-
def initialize(err, out, status)
|
5
|
-
@err = err
|
6
|
-
@out = out
|
7
|
-
@status = status
|
8
|
-
puts @out
|
9
|
-
end
|
10
|
-
|
11
|
-
def settings
|
12
|
-
return @settings unless @settings.nil?
|
13
|
-
@settings = Hash.new
|
14
|
-
@out.each_line do |line|
|
15
|
-
return @settings if line.match('loss')
|
16
|
-
line.match(/\s=\s/) do |m|
|
17
|
-
label, value = split_line(line)
|
18
|
-
@settings[format_label(label)] = format_value(value)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def sample
|
24
|
-
return @sample unless @sample.nil?
|
25
|
-
@sample = Array.new
|
26
|
-
found = false
|
27
|
-
@out.each_line do |line|
|
28
|
-
if line.match(/^\n/)
|
29
|
-
return @sample
|
30
|
-
end
|
31
|
-
if line.match('loss')
|
32
|
-
found = true
|
33
|
-
next
|
34
|
-
end
|
35
|
-
if found == true
|
36
|
-
average_loss, since_last, example_counter, example_weight, current_label, current_predict, current_features = line.scan(/\d+\.?\d*/)
|
37
|
-
@sample.push({
|
38
|
-
:average_loss => average_loss,
|
39
|
-
:since_last => since_last,
|
40
|
-
:example_counter => example_counter,
|
41
|
-
:example_weight => example_weight,
|
42
|
-
:current_label => current_label,
|
43
|
-
:current_predict => current_predict,
|
44
|
-
:current_features => current_features
|
45
|
-
})
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def results
|
51
|
-
return @settings unless @settings.nil?
|
52
|
-
@settings = Hash.new
|
53
|
-
@out.each_line do |line|
|
54
|
-
if line.match('finished run')
|
55
|
-
found = true
|
56
|
-
next
|
57
|
-
end
|
58
|
-
if found == true
|
59
|
-
line.match(/\s=\s/) do |m|
|
60
|
-
label, value = split_line(line)
|
61
|
-
@settings[format_label(label)] = format_value(value)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def split_line(line)
|
70
|
-
line.split(/\s=\s/)
|
71
|
-
end
|
72
|
-
|
73
|
-
def format_label(label)
|
74
|
-
label.gsub(' ', '_').downcase.to_sym
|
75
|
-
end
|
76
|
-
|
77
|
-
def format_value(value)
|
78
|
-
value.delete("\n")
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
data/lib/bors/prediction.rb
DELETED