title: How to transform the dataframe into label feature vector?
body: <p>I am running a logistic regression modl in scala and I have a data frame like below:</p>
  
  <p>df</p>
  
  <pre><code>+-----------+------------+
  |x          |y           |
  +-----------+------------+
  |          0|           0|
  |          0|          33|
  |          0|          58|
  |          0|          96|
  |          0|           1|
  |          1|          21|
  |          0|          10|
  |          0|          65|
  |          1|           7|
  |          1|          28|
  +-----------+------------+
  </code></pre>
  
  <p>I need to tranform this into something like this</p>
  
  <pre><code>+-----+------------------+
  |label|      features    | 
  +-----+------------------+
  |  0.0|(1,[1],[0])       |
  |  0.0|(1,[1],[33])      |
  |  0.0|(1,[1],[58])      |
  |  0.0|(1,[1],[96])      |
  |  0.0|(1,[1],[1])       |
  |  1.0|(1,[1],[21])      |
  |  0.0|(1,[1],[10])      |
  |  0.0|(1,[1],[65])      |
  |  1.0|(1,[1],[7])       |
  |  1.0|(1,[1],[28])      | 
  +-----------+------------+
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code> val lr = new LogisticRegression()
             .setMaxIter(10)
             .setRegParam(0.3)
             .setElasticNetParam(0.8)
  
        val assembler = new VectorAssembler()
    .setInputCols(Array("x"))
    .setOutputCol("Feature")
    var lrModel=  lr.fit(daf.withColumnRenamed("x","label").withColumnRenamed("y","features"))
  </code></pre>
  
  <p>Any help is appreciated.</p>