This commit is contained in:
tqchen
2015-01-26 10:27:44 -08:00
parent 72f6fbd46f
commit c34367b207
4 changed files with 37 additions and 0 deletions

14
demo/yearpredMSD/csv2libsvm.py Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/python
import sys
if len(sys.argv) < 3:
print 'Usage: <csv> <libsvm>'
print 'convert a all numerical csv to libsvm'
fo = open(sys.argv[2], 'w')
for l in open(sys.argv[1]):
arr = l.split(',')
fo.write('%s' % arr[0])
for i in xrange(len(arr) - 1):
fo.write(' %d:%s' % (i, arr[i+1]))
fo.close()