309069 (11) [Avatar] Offline
[ 5 KB ]
I get the following error when trying to perform "predictions" (see also attached file):

scala> val predictions = model.transform(testingData)
java.lang.ClassCastException: org.apache.spark.ml.attribute.UnresolvedAttribute$ cannot be cast to org.apache.spark.ml.attribute.NominalAttribute
at org.apache.spark.ml.feature.IndexToString.transform(StringIndexer.scala:313)
at org.apache.spark.ml.PipelineModel$$anonfun$transform$1.apply(Pipeline.scala:299)
at org.apache.spark.ml.PipelineModel$$anonfun$transform$1.apply(Pipeline.scala:299)
at scala.collection.IndexedSeqOptimized$class.foldl(IndexedSeqOptimized.scala:57)
at scala.collection.IndexedSeqOptimized$class.foldLeft(IndexedSeqOptimized.scala:66)
at scala.collection.mutable.ArrayOps$ofRef.foldLeft(ArrayOps.scala:186)
at org.apache.spark.ml.PipelineModel.transform(Pipeline.scala:299)
... 48 elided

Note (nothing to do with the error): I had to comment .setLabels(labelIndexer.labels) since "labels" is not sopprted in StringIndexer
Jeff Smith (14) [Avatar] Offline
From the data that you've provided me, it's not entirely clear what the problem is. Looks like you just need to satisfy Spark that the column is of the type that it needs to be. Have you investigated the example code in the GitHub repo for possible differences between it and what you tried? https://github.com/jeffreyksmithjr/reactive-machine-learning-systems