title: How to cast a variable of type ML sparse vector type to MLlib sparse vector type?
body: <p>When I try to create the labelled points from output of Vector Transformer, I am facing the following problem:</p>
  
  <pre><code>  val realout = output.select("label","features").rdd.map(row =&gt; LabeledPoint
     row.getAs[Double]("label"),
  row.getAs[org.apache.spark.mllib.linalg.SparseVector]("features")
  ))
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>enter [error] (run-main-0) org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 13.0 failed 1 times, most recent failure: Lost task 0.0 in stage 13.0 (TID 13, localhost): java.lang.ClassCastException: org.apache.spark.ml.linalg.SparseVector cannot be cast to org.apache.spark.mllib.linalg.Vector
  [error]     at DataCleaning$$anonfun$1.apply(DataCleaning.scala:107
  [error]     at DataCleaning$$anonfun$1.apply(DataCleaning.scala:105)
  [error] 
  at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
  [error]
  at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:462
  [error]
  atorg.apache.spark.storage.memory.MemoryStore.putIteratorAsValues(MemoryStore.scala:213)
  </code></pre>
  
  <p>I checked the solution provided in the link<a href="https://stackoverflow.com/questions/38818879/matcherror-while-accessing-vector-column-in-spark-2-0">1</a> which explain conversion of a vector in spark 2.0.0, but facing a compilation error as mentioned below,</p>
  
  <pre><code>object linalg is not a member of package org.apache.spark.ml
  </code></pre>
  
  <p>Kindly Help . Thanks !</p>