title: How to apply K nearest neighbor in spark?
body: <p>I have a parquet file (id,features).I want to apply KNN as classifier .I used pca algorithm to reduce dimensions then knn.</p>
  
  <pre><code>    val dataset =  spark.read.parquet("/usr/local/spark/dataset/data/user")
            .toDF()
  
     val Array(train, test) = dataset.randomSplit(Array(0.8, 0.2), seed = 1234L).map(_.cache())
  
          val pca = new PCA()
            .setInputCol("features")
            .setK(50)
            .setOutputCol("pcaFeatures")
          val knn = new KNNClassifier()
            .setTopTreeSize(50)
            .setFeaturesCol("pcaFeatures")
            .setPredictionCol("prediction")
            .setK(1)
  
          val pipeline = new Pipeline()
            .setStages(Array(pca, knn))
  
          val paramGrid = new ParamGridBuilder()
      //      .addGrid(knn.k, 1 to 20)
            .addGrid(pca.k, 10 to 100 by 10)
            .build()
  
          val cv = new CrossValidator()
            .setEstimator(pipeline)
            .setEvaluator(new MulticlassClassificationEvaluator)
            .setEstimatorParamMaps(paramGrid)
            .setNumFolds(5)
  </code></pre>
  
  <p>But give me this error.How to solve it?</p>
  
  <pre><code>requirement failed: Column features must be of type org.apache.spark.ml.linalg.VectorUDT@3bfc3ba7 but was actually ArrayType(DoubleType,true).
  </code></pre>