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/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
@@ -1,19 +0,0 @@
1
- class Bors
2
- class Prediction
3
- class Result
4
-
5
- def initialize(result)
6
- @result = result.split(' ')
7
- end
8
-
9
- def tag
10
- @result[1]
11
- end
12
-
13
- def value
14
- @result[0]
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- require_relative "prediction/result"
2
-
3
- class Bors
4
- class Prediction
5
-
6
- def initialize(output)
7
- @output = output
8
- end
9
-
10
- def each(&block)
11
- @output.each_line do |line|
12
- block.call( Result.new(line) )
13
- end
14
- end
15
-
16
- end
17
- end