-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Description
I did something like this:
#convert to libsvm format https://github.com/zygmuntz/phraug/blob/master/csv2libsvm.py
#python csv2libsvm.py spambase_renamed_class.csv libsvm.data -1 False
data = open("spambase/libsvm.data", "r")
data2 = open("spambase/libsvm2.data", "a")
i = 0
for line in data:
temp = line[-3:]
white_space_index = line[2:].find(" ")
if i == 0:
white_space_index = 0
i += 1
if "-1" in temp:
line = "-1 " + line[white_space_index + 2:-6]
else:
line = "1 " + line[white_space_index + 2:-6]
#drop last index (class) and first because it is the index nr.
data2.write(line + "\n")
data.close()
data2.close()
Metadata
Metadata
Assignees
Labels
No labels