简体   繁体   English

Apache Flink中的流式预测

[英]Streaming Predictions in Apache Flink

Is it possible to make predictions on a dataStream in Apache Flink using a model that is already trained in batch? 是否可以使用已经批量训练的模型对Apache Flink中的dataStream进行预测?

The predict function from svm needs as input a dataset and does not take a datastream. svm的预测函数需要将数据集作为输入,而不需要数据流。

Unfortunately I am not able to figure it out how I can make it work with a flatpMap/map function. 不幸的是,我无法弄清楚如何使用flatpMap / map函数。

I trained my SVM-model this way: 我以这种方式训练了我的SVM模型:

val svm2 = SVM() val svm2 = SVM()
svm2.setSeed(1) svm2.setSeed(1)
svm2.fit(trainLV) svm2.fit(trainLV)
val testVD = testLV.map(lv => (lv.vector, lv.label)) val testVD = testLV.map(lv =>(lv.vector,lv.label))
val evalSet = svm2.evaluate(testVD) val evalSet = svm2.evaluate(testVD)

and saved the model: val modelSvm = svm2.weightsOption.get 并保存模型:val modelSvm = svm2.weightsOption.get

Then I have an incoming datastream in the streaming environment: 然后我在流环境中有一个传入的数据流:
dataStream[(Int, Int, Int)] dataStream [(Int,Int,Int)]
which should be bininary classified using the svm model. 应该使用svm模型进行二进制分类。

Thank you! 谢谢!

Flink's ML library only supports batch processing at the moment. Flink的ML库目前仅支持批处理。 If you want to make predictions using the DataStream API, you would need to implement your own flatMap / map function which takes the model and applies it to the incoming events. 如果您想使用DataStream API进行预测,则需要实现自己的flatMap / map函数,该函数将模型flatMap到传入事件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM