Last active
November 24, 2016 18:29
-
-
Save alculquicondor/dfac40bd8b1c075d3d758964c27429af to your computer and use it in GitHub Desktop.
Scripts for converting to OPF format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fi = open('letter-recognition.data') | |
fo = open('letter.txt', 'w') | |
fo.write('20000 26 16\n') | |
for i, line in enumerate(fi): | |
line = line.strip().split(',') | |
line[0] = str(int(ord(line[0]) - 64)) | |
line = [str(i)] + line | |
fo.write(' '.join(line) + '\n') | |
fi.close() | |
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
fi = open('miniboone_orig.txt') | |
fo = open('miniboone.txt', 'w') | |
n, m = (int(x) for x in fi.readline().split()) | |
fo.write('%d 2 50\n' % (n + m)) | |
for i in range(n): | |
fo.write('%d 1 ' % i) | |
fo.write(fi.readline()) | |
fo.write('\n') | |
for i in range(m): | |
fo.write('%d 2 ' % (i + n)) | |
fo.write(fi.readline().strip()) | |
fo.write('\n') | |
fi.close() | |
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 58509 | |
attrs = 48 | |
classes = 11 | |
fi = open('sensorless_drive_diagnosis.txt') | |
fo = open('sdd.opf.txt', 'w') | |
fo.write('%d %d %d\n' % (n, classes, attrs)) | |
for i in range(n): | |
line = fi.readline().split() | |
label = int(line[-1]) | |
fo.write('%d %d %s\n' % (i, label, ' '.join(line[:-1]))) | |
fi.close() | |
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
fi = open(sys.argv[1]) | |
fo = open(sys.argv[2], 'w') | |
fo.write('%s 7 9\n' % sys.argv[3]) | |
for i, line in enumerate(fi): | |
line = line.strip().split(' ') | |
line = [str(i), line[-1]] + line[:-1] | |
fo.write(' '.join(line) + '\n') | |
fi.close() | |
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 245057 | |
attrs = 3 | |
classes = 2 | |
fi = open('skin.txt') | |
fo = open('skin.opf.txt', 'w') | |
fo.write('%d %d %d\n' % (n, classes, attrs)) | |
for i in range(n): | |
line = fi.readline().split() | |
label = int(line[-1]) | |
fo.write('%d %d %s\n' % (i, label, ' '.join(line[:-1]))) | |
fi.close() | |
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fi = open('SUSY.csv') | |
fo = open('SUSY.txt', 'w') | |
fo.write('5000000 2 18\n') | |
for i, line in enumerate(fi): | |
line = line.strip().split(',') | |
line[0] = str(int(float(line[0])) + 1) | |
line = [str(i)] + line | |
fo.write(' '.join(line) + '\n') | |
fi.close() | |
fo.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment