ClassCastException on spark PipelineModel created from loadSparkBundle
Hi,
Props to the creators and maintainers of the mleap library. I have used it for run time and it's serving speed is blazing fast. I ran in to one error while implementing mleap library for our usecase
We have a logistic regression model that was serialized as a mleap bundle and I created spark PipelineModel from the bundle file using .loadSparkBundle().get.root.
However, the transform on PipelineModel failed with error java.lang.ClassCastException: org.apache.spark.ml.attribute.UnresolvedAttribute$ cannot be cast to org.apache.spark.ml.attribute.NominalAttribute due to labels not set on IndexToString transformer
I was able to workaround the issue by creating the IndexToString transformer with labels. This looks like a bug, would you like me to create a PR? WDYT?
diff --git a/mleap-spark/src/main/scala/org/apache/spark/ml/bundle/ops/feature/ReverseStringIndexerOp.scala b/mleap-spark/src/main/scala/org/apache/spark/ml/bundle/ops/feature/ReverseStringIndexerOp.scala
index 1b012f2..bcc80d4 100644
--- a/mleap-spark/src/main/scala/org/apache/spark/ml/bundle/ops/feature/ReverseStringIndexerOp.scala
+++ b/mleap-spark/src/main/scala/org/apache/spark/ml/bundle/ops/feature/ReverseStringIndexerOp.scala
@@ -66,7 +66,7 @@ class ReverseStringIndexerOp extends SimpleSparkOp[IndexToString] {
}
override def sparkLoad(uid: String, shape: NodeShape, model: IndexToString): IndexToString = {
- new IndexToString(uid = uid)
+ new IndexToString(uid = uid).setLabels(model.getLabels)
}
override def sparkInputs(obj: IndexToString): Seq[ParamSpec] = {
Kiran’s-MacBook-Pro:mleap kiranchitturi$
Hi @kiranchitturi , I am facing similar issue. Were you able to find a fix for this ?
Facing the same issue.
Fixed has been applied on mleap master https://github.com/combust/mleap/blob/master/mleap-spark/src/main/scala/org/apache/spark/ml/bundle/ops/feature/ReverseStringIndexerOp.scala#L69, closing this. Please re-open if you still an issue.