title: LIBSVM data preparation
body: <p>I am doing a project on Image processing in Matlab and wish to implement LIBSVM for supervised learning. </p>
  
  <p>I am encountering a problem in data preparation. 
  I have the data in CSV format and when i try to convert it into libsvm format by using the information provided in LIBSVM faq:-</p>
  
  <pre><code>    matlab&gt; SPECTF = csvread('SPECTF.train'); % read a csv file
      matlab&gt; labels = SPECTF(:, 1); % labels from the 1st column
      matlab&gt; features = SPECTF(:, 2:end); 
      matlab&gt; features_sparse = sparse(features); % features must be in a sparse matrix
      matlab&gt; libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);
  </code></pre>
  
  <p>I get the data in the following form:</p>
  
  <p>3.0012 1:2.1122 2:0.9088 ......
  [value 1] [index 1]:[value 2] [index 2]:[value 3] </p>
  
  <p>That is the first value takes no index and the value following the index 1 is value 2.</p>
  
  <p>From what i had read, the data should be in the following format:</p>
  
  <p>[label] [index 1]:[value 1] [index 2]:[value 2]......</p>
  
  <p>[label] [index 1]:[value 1] [index 2]:[value 2]......</p>
  
  <p>I need help to make this right.
  And also if anyone would give me a clue about how to give labels it will be really helpful.</p>
  
  <p>Thanking you in advance,
  Sidra</p>