title: convert Seq[(String, Any)] to Seq[(String, org.apache.spark.ml.PredictionModel[_, _])] in spark
body: <p>i had trained my dataset into different models such as nbModel, dtModel, rfModel, GbmModel . All these are machine learning models</p>
  
  <p>now when i am saving it into a variable as </p>
  
  <pre><code>val models = Seq(("NB", nbModel), ("DT", dtModel), ("RF", rfModel), ("GBM",gbmModel))
  </code></pre>
  
  <p>i am getting a Seq[(String, Any)]</p>
  
  <pre><code>models: Seq[(String, Any)] = List((NB,NaiveBayesModel (uid=nb_c35f79982850) with 2 classes), (DT,()), (RF,RandomForestClassificationModel (uid=rfc_3f42daf4ea14) with 15 trees), (GBM,GBTClassificationModel (uid=gbtc_534a972357fa) with 20 trees))
  </code></pre>
  
  <p>if an individual model such as nbModel</p>
  
  <pre><code> val models = ("NB", nbModel)
  </code></pre>
  
  <p>OUTPUT : <code>models: (String, org.apache.spark.ml.classification.NaiveBayesModel) = (NB,NaiveBayesModel (uid=nb_c35f79982850) with 2 classes)
  </code></p>
  
  <p>and when i am trying to merge few columns from those models i am getting type mismatch error</p>
  
  <pre><code>val mlTrainData= mlData(transferData, "value", models).drop("row_id")
  </code></pre>
  
  <p><code>&lt;console&gt;:75: error: type mismatch;
   found   : Seq[(String, Any)]
   required: Seq[(String, org.apache.spark.ml.PredictionModel[_, _])]
         val mlTrainData= mlData(transferData, "value", models).drop("row_id")</code></p>
  
  <p>Also my MlDATA is</p>
  
  <pre><code>def mlData(inputData: DataFrame, responseColumn: String, baseModels:
   | Seq[(String, PredictionModel[_, _])]): DataFrame= {
   | baseModels.map{ case(name, model) =&gt;
   | model.transform(inputData)
   | .select("row_id", model.getPredictionCol )
   | .withColumnRenamed("prediction", s"${name}_prediction")
   | }.reduceLeft((a, b) =&gt;a.join(b, Seq("row_id"), "inner"))
   | .join(inputData.select("row_id", responseColumn), Seq("row_id"),
   | "inner")
   | }
  </code></pre>
  
  <p>OUTPUT: <code>mlData: (inputData: org.apache.spark.sql.DataFrame, responseColumn: String, baseModels: Seq[(String, org.apache.spark.ml.PredictionModel[_, _])])org.apache.spark.sql.DataFrame
  </code></p>