简体   繁体   中英

Translate Flink scala into java

The Flink doc gives a scala example for SVM algorithm:

val trainingDS: DataSet[LabeledVector] = env.readLibSVM(pathToTrainingFile)
val svm = SVM()
.setBlocks(10)

// Learn the SVM model
svm.fit(trainingDS)

How would the call to "fit" translate to java?

(The java expression "svm.fit(trainingDS)" gives a java compiler error:

"The method fit(DataSet, ParameterMap, FitOperation) in the type SVM is not applicable for the arguments (DataSet)" )

At the moment, FlinkML can only be used with Scala. The reason is that FlinkML comes with a flexible pipeline mechanism which allows you to easily construct data analysis pipelines. These pipelines can consist of an arbitrary number of Estimators and a single trailing Predictor .

The implementation of this mechanism relies on type classes which encapsulate the program logic. The type classes are automatically retrieved and chained by declaring them as implicit values. Thus, the Scala compiler will make sure that the correct program logic is executed.

In theory, it is possible to construct these pipelines manually. However, it is a laborious process and, thus, I would recommend you to simply use Flink's Scala API if you want to interact with FlinkML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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