私は予測のためにSpark MLlibのDecisionTreeModelを使用しています。ClassCastException [Cを[Ljava.lang.Object;にキャストできません。
def predict(sc: SparkContext) : (Row => Row) = {
val model = DecisionTreeModel.load(sc,"hdfs://invlxiisqa09.informatica.com:8020/user/cloudqa/anuja/myDecisionTreeClassificationModel")
(str:Row)=> {
val mldata5 = Vectors.dense(str.get(0).asInstanceOf[Int],str.get(1).asInstanceOf[Int], str.get(2).asInstanceOf[Int] , str.get(3).asInstanceOf[Int], str.get(4).asInstanceOf[Int], str.get(5).asInstanceOf[Int], str.get(6).asInstanceOf[Int], str.get(7).asInstanceOf[Int])
val prediction = Row.fromSeq(String.valueOf(model.predict(mldata5)).toSeq)
prediction
}
}
私は、次のデータを送信
[12.0,0.0,1620.0,1850.0,6.0,270.0,234.0,270.0]
行を作成しながら、私はClassCastException
を取得します。
誰かが私が間違っている場所を指摘できますか?
スタックトレースです
java.lang.ClassCastException: [C cannot be cast to [Ljava.lang.Object;
at org.apache.spark.sql.Row$.fromSeq(Row.scala:53)
at com.informatica.bootstrap.InfaStreaming$$anonfun$predicts$1.apply(InfaStreaming.scala:256)
at com.informatica.bootstrap.InfaStreaming$$anonfun$predicts$1.apply(InfaStreaming.scala:253)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at com.informatica.bootstrap.InfaStreaming$$anonfun$jsonPayloadGenerator$1$$anon$3.next(InfaStreaming.scala:946)
at com.informatica.bootstrap.InfaStreaming$$anonfun$jsonPayloadGenerator$1$$anon$3.next(InfaStreaming.scala:943)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
at scala.collection.convert.Wrappers$IteratorWrapper.next(Wrappers.scala:31)
at com.informatica.adapter.streaming.kafka.common.KafkaOperations.sendMessagesBinary(KafkaOperations.java:308)
at com.informatica.bootstrap.InfaStreaming$$anonfun$writeToKafka$2$$anonfun$apply$26.apply(InfaStreaming.scala:274)
at com.informatica.bootstrap.InfaStreaming$$anonfun$writeToKafka$2$$anonfun$apply$26.apply(InfaStreaming.scala:272)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:925)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:925)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
at org.apache.spark.scheduler.Task.run(Task.scala:99)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
完全なスタックトレースを投稿できますか? – aclokay
java.lang.ClassCastException:[Cは[Ljava.lang.Object;にキャストできません。 \t at org.apache.spark.sql.Row $ .fromSeq(Row.scala:53) – shivali