I am doing a project using libsvm and I am preparing my data to use the lib. How can I convert CSV file to LIBSVM compatible data?
<blockquote>
CSV File:
<a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/data/iris.csv" rel="nofollow">https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/data/iris.csv</a>
</blockquote>
In the frequencies questions:
<blockquote>
How to convert other data formats to LIBSVM format?
It depends on your data format. A simple way is to use libsvmwrite in the libsvm matlab/octave interface. Take a CSV (comma-separated values) file in UCI machine learning repository as an example. We download SPECTF.train. Labels are in the first column. The following steps produce a file in the libsvm format.
</blockquote>
but I don't wanna use matlab, I use python.
I found this solution as well using <a href="http://nayefreza.wordpress.com/2013...le-to-libsvm-compatible-data-file-using-java/" rel="nofollow">JAVA</a>
Can anyone recommend a way to tackle this problem ?
<blockquote>
CSV File:
<a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/data/iris.csv" rel="nofollow">https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/data/iris.csv</a>
</blockquote>
In the frequencies questions:
<blockquote>
How to convert other data formats to LIBSVM format?
It depends on your data format. A simple way is to use libsvmwrite in the libsvm matlab/octave interface. Take a CSV (comma-separated values) file in UCI machine learning repository as an example. We download SPECTF.train. Labels are in the first column. The following steps produce a file in the libsvm format.
</blockquote>
Code:
matlab> SPECTF = csvread('SPECTF.train'); % read a csv file
matlab> labels = SPECTF(:, 1); % labels from the 1st column
matlab> features = SPECTF(:, 2:end);
matlab> features_sparse = sparse(features); % features must be in a sparse matrix
matlab> libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);
The tranformed data are stored in SPECTFlibsvm.train.
Alternatively, you can use convert.c to convert CSV format to libsvm format.
but I don't wanna use matlab, I use python.
I found this solution as well using <a href="http://nayefreza.wordpress.com/2013...le-to-libsvm-compatible-data-file-using-java/" rel="nofollow">JAVA</a>
Can anyone recommend a way to tackle this problem ?