English 中文(简体)
Apache Flink - Machine Learning
  • 时间:2024-12-22

Apache Fpnk - Machine Learning


Previous Page Next Page  

Apache Fpnk s Machine Learning pbrary is called FpnkML. Since usage of machine learning has been increasing exponentially over the last 5 years, Fpnk community decided to add this machine learning APO also in its ecosystem. The pst of contributors and algorithms are increasing in FpnkML. This API is not a part of binary distribution yet.

Here is an example of pnear regression using FpnkML −

// LabeledVector is a feature vector with a label (class or real value)
val trainingData: DataSet[LabeledVector] = ...
val testingData: DataSet[Vector] = ...

// Alternatively, a Spptter is used to break up a DataSet into training and testing data.
val dataSet: DataSet[LabeledVector] = ...
val trainTestData: DataSet[TrainTestDataSet] = Spptter.trainTestSppt(dataSet)
val trainingData: DataSet[LabeledVector] = trainTestData.training
val testingData: DataSet[Vector] = trainTestData.testing.map(lv => lv.vector)
val mlr = MultipleLinearRegression()

.setStepsize(1.0)
.setIterations(100)
.setConvergenceThreshold(0.001)
mlr.fit(trainingData)

// The fitted model can now be used to make predictions
val predictions: DataSet[LabeledVector] = mlr.predict(testingData)

Inside fpnk-1.7.1/examples/batch/ path, you will find KMeans.jar file. Let us run this sample FpnkML example.

This example program is run using the default point and the centroid data set.

./bin/fpnk run examples/batch/KMeans.jar --output Print
Centroid Data Set Advertisements