title: How to convert a map to Spark's RDD
body: <p>I have a data set which is in the form of some nested maps, and its Scala type is:</p>
  
  <pre><code>Map[String, (LabelType,Map[Int, Double])]
  </code></pre>
  
  <p>The first <code>String</code> key is a unique identifier for each sample, and the value is a tuple that contains the label (which is -1 or 1), and a nested map which is the sparse representation of the non-zero elements which are associated with the sample.</p>
  
  <p>I would like to load this data into Spark (using MUtil) and train and test some machine learning algorithms.</p>
  
  <p>It's easy to write this data into a file with LibSVM's sparse encoding, and then load it in Spark:</p>
  
  <pre><code>writeMapToLibSVMFile(data_map,"libsvm_data.txt") // Implemeneted some where else
  val conf = new SparkConf().setAppName("DecisionTree").setMaster("local[4]")
  val sc = new SparkContext(conf)
  
  // Load and parse the data file.
  val data = MLUtils.loadLibSVMFile(sc, "libsvm_data.txt")
  // Split the data into training and test sets
  val splits = data.randomSplit(Array(0.7, 0.3))
  val (trainingData, testData) = (splits(0), splits(1))
  
  // Train a DecisionTree model.
  </code></pre>
  
  <p>I know it should be as easy to directly load the <code>data</code> variable from <code>data_map</code>, but I don't know how. </p>
  
  <p>Any help is appreciated!</p>