flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-2297] [ml] Add threshold setting for SV...
Date Wed, 01 Jul 2015 08:50:55 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/874#discussion_r33659515
  
    --- 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 --
    
    hmm you could manually set the weight vector for which you are sure that something different
than 1/-1 is calculated


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message