title: Spark: How to transform a RDD to Seq to be used in pipeline
body: <p>I want to use the implementation of pipeline in MLlib. Before, I had a RDD file and pass it to the model creation, but now to use pipeline, there should be sequence of LabeledDocument to be passed to the pipeline.</p>
  
  <p>I have my RDD which is created as follows: </p>
  
  <pre><code>val data = sc.textFile("/test.csv");
  val parsedData = data.map { line =&gt;
          val parts = line.split(',')
          LabeledPoint(parts(0).toDouble, Vectors.dense(parts.tail))
          }.cache()
  </code></pre>
  
  <p>In the pipeline example <a href="https://spark.apache.org/docs/1.2.0/ml-guide.html" rel="nofollow">Spark Programming Guide</a>, the pipeline needs the following data:</p>
  
  <pre><code>// Prepare training documents, which are labeled.
  val training = sparkContext.parallelize(Seq(
    LabeledDocument(0L, "a b c d e spark", 1.0),
    LabeledDocument(1L, "b d", 0.0),
    LabeledDocument(2L, "spark f g h", 1.0),
    LabeledDocument(3L, "hadoop mapreduce", 0.0),
    LabeledDocument(4L, "b spark who", 1.0),
    LabeledDocument(5L, "g d a y", 0.0),
    LabeledDocument(6L, "spark fly", 1.0),
    LabeledDocument(7L, "was mapreduce", 0.0),
    LabeledDocument(8L, "e spark program", 1.0),
    LabeledDocument(9L, "a e c l", 0.0),
    LabeledDocument(10L, "spark compile", 1.0),
    LabeledDocument(11L, "hadoop software", 0.0)))
  </code></pre>
  
  <p>I need a way to change my RDD (parsedData) to sequence of LabeledDocuments (like training in the example).</p>
  
  <p>I appreciate your help.</p>