summaryrefslogtreecommitdiff
path: root/data/iris/2svmlight.rb
diff options
context:
space:
mode:
Diffstat (limited to 'data/iris/2svmlight.rb')
-rwxr-xr-xdata/iris/2svmlight.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/data/iris/2svmlight.rb b/data/iris/2svmlight.rb
new file mode 100755
index 0000000..7307262
--- /dev/null
+++ b/data/iris/2svmlight.rb
@@ -0,0 +1,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
+