lundi 26 mai 2014

How to load dataset in libsvm python


Vote count:

0




I am wandering how can I load my dataset, in order to read it from libsvm python implementation. My data is a 250X500 matrix and the first column is dataset labels. I am using the following code in order to read the data:



with open("dataset3.txt") as textFile:
lines = [line.split() for line in textFile]

Matrix = [[0 for x in xrange(len(lines[0]))] for x in xrange(len(lines))]

for y in range(0, len(lines)):
for x in range(0, len(lines[0])):
Matrix[y][x] = lines[y][x]


With the code above I read my data into a 2d array. How can I use this array in order to perform svm train and evaluation??



asked 31 secs ago






Aucun commentaire:

Enregistrer un commentaire