summaryrefslogtreecommitdiff
path: root/data/iris/svm_light_format.rb
blob: 7307262a5ea7be8b51240aed3932596d11f32f8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby


label1 = "Iris-"+ARGV[0]

while line = STDIN.gets
  line.strip!
  a = line.split ','
  label = -1
  label = 1 if a[-1]==label1
  a = a[0..a.size-2]
  f = []
  a.each_with_index { |i,idx|
     f<<"#{idx+1}:#{i.to_f}"
  }
  puts "#{label} #{f.join(' ')}"
end