Github user thvasilo commented on a diff in the pull request:
https://github.com/apache/flink/pull/874#discussion_r33570883
--- Diff:
flink-staging/flink-ml/src/test/scala/org/apache/flink/ml/classification/SVMITSuite.scala
---
@@ -69,19 +70,38 @@ class SVMITSuite extends FlatSpec with Matchers with
FlinkTestBase {
svm.fit(trainingDS)
- val threshold = 0.0
-
- val predictionPairs = svm.evaluate(test).map {
- truthPrediction =>
- val truth = truthPrediction._1
- val prediction = truthPrediction._2
- val thresholdedPrediction = if (prediction > threshold) 1.0 else
-1.0
- (truth, thresholdedPrediction)
- }
+ val predictionPairs = svm.evaluate(test)
val absoluteErrorSum = predictionPairs.collect().map{
case (truth, prediction) => Math.abs(truth - prediction)}.sum
absoluteErrorSum should be < 15.0
}
+
+ it should "be possible to get the raw decision function values" in {
+ val env = ExecutionEnvironment.getExecutionEnvironment
+
+ val svm = SVM().
+ setBlocks(env.getParallelism).
+ setIterations(100).
+ setLocalIterations(100).
+ setRegularization(0.002).
+ setStepsize(0.1).
+ setSeed(0).
+ clearThreshold()
+
+ val trainingDS = env.fromCollection(Classification.trainingData)
+
+ val test = trainingDS.map(x => x.vector)
+
+ svm.fit(trainingDS)
+
+ val predictions: DataSet[(FlinkVector, Double)] = svm.predict(test)
+
+ val preds = predictions.map(vectorLabel => vectorLabel._2).collect()
+
+ preds.max should be > 1.0
--- End diff --
Better way to check raw values vs. 1/-1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---