def to_libSVM (sel_features = nil)
      
      #Load the selected features into a Hash
      sf = Hash.new
      if (sel_features)
        sel_features.each do |f| 
          sf[f] = 1 
        end
      end
      
      self.define_features if (@train) #This method is needed only for training data
      
      output = Array.new
      @fvs.each do |vector, label|
        line = Array.new
        line.push(label)
        
        (1..@features.f_count).each do |id| #OPTIMIZE: Change this line to consider sorting in case of terms being features
          term = @features.term(id)
          if ( value = vector[term] ) then
            line.push([id, value].join(":")) if sf[term] or not sel_features
          end
        end
        output.push(line.join(" "))
      end
      output.join("\n")
    end
def to_libSVM (sel_features = nil)
      
      #Load the selected features into a Hash
      sf = Hash.new
      if (sel_features)
        sel_features.each do |f| 
          sf[f] = 1 
        end
      end
      
      self.define_features if (@train) #This method is needed only for training data
      
      output = Array.new
      @fvs.each do |vector, label|
        line = Array.new
        line.push(label)
        
        (1..@features.f_count).each do |id| #OPTIMIZE: Change this line to consider sorting in case of terms being features
          term = @features.term(id)
          if ( value = vector[term] ) then
            line.push([id, value].join(":")) if sf[term] or not sel_features
          end
        end
        output.push(line.join(" "))
      end
      output.join("\n")
    end
Creates feature vectors and converts them to
 LibSVM format -- a multiline string with one
 data point per line

 If provided with a list of selected features then
 insert only those features