我已经训练过多元回归模型,现在我想用它来预测。
阅读documents我理解输入是带标签的向量,输出是带有元组[ InputValue,PredictValue ]的数据集,对吗?
我创建了带标签的Vector:
val mapped = data.map {x => new org.apache.flink.ml.common.LabeledVector (x._4, org.apache.flink.ml.math.DenseVector(x._1,x._2,x._3)) }
//Print
mapped: org.apache.flink.api.scala.DataSet[org.apache.flink.ml.common.LabeledVector] = org.apache.flink.api.scala.DataSet@7d4fefdc
LabeledVector(6.7, DenseVector(33.0, -52.26, 28.3))
LabeledVector(5.8, DenseVector(36.0, 45.53, 150.93))
.....
我创建并训练了我的模型,我预测:
// Calculate the predictions for the test data
val predictions = mlr.predict(mapped)
我得到了错误:
java.lang.RuntimeException: There is no PredictOperation defined for org.apache.flink.ml.regression.MultipleLinearRegression which takes a DataSet[org.apache.flink.ml.common.LabeledVector] as input.
但是你可以看到here官方文档说它会退出。
感谢您的帮助! :)