cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.52k stars 1.64k forks source link

Csv2libsvm converter added #172

Open dasmehdix opened 3 years ago

dasmehdix commented 3 years ago

Hi, I wrote a basic script to convert a classical "csv" file to libsvm format.Explanation is added.

A classical csv format is like (as an example):

classs accelX accelY accelZ gyroX gyroY gyroZ
1 -0.329013 1.111466 9.943973 0.064446 -0.0759 -0.095295
1 -0.329013 1.111466 9.943973 0.064446 -0.0759 -0.095295

Converted to: 1 1:-0.329013 2:1.111466 3:9.943973 4:0.064446 5:-0.0759 6:-0.095295 1 1:-0.329013 2:1.111466 3:9.943973 4:0.064446 5:-0.0759 6:-0.09529

Also, a csv sample and desired output uploaded to test script.

Hope this basic script help the community.