Class: ML::Data::Parser
- Inherits:
-
Object
- Object
- ML::Data::Parser
- Defined in:
- lib/data/parser.rb
Overview
Parser for traing/testing data
Instance Method Summary collapse
-
#parse_supervised(filename) ⇒ Hash
Parse the vector file with supervised result.
-
#parse_unsupervised(filename) ⇒ Array
Parse the vector file.
Instance Method Details
#parse_supervised(filename) ⇒ Hash
Parse the vector file with supervised result
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/data/parser.rb', line 9 def parse_supervised filename result = {} lines = IO.readlines(filename) lines.each do |line| splitted = line.split.map(&:to_f) result[splitted[1..-1] + [1.0]] = splitted[0] end result end |
#parse_unsupervised(filename) ⇒ Array
Parse the vector file
25 26 27 28 |
# File 'lib/data/parser.rb', line 25 def parse_unsupervised filename lines = IO.readlines(filename) lines.map {|line| line.split.map(&:to_f) } end |