Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15149#discussion_r79864108
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/ProbabilisticClassifierSuite.scala
 ---
    @@ -48,13 +48,28 @@ class ProbabilisticClassifierSuite extends 
SparkFunSuite {
         val thresholds = Array(0.5, 0.2)
         val testModel = new TestProbabilisticClassificationModel("myuid", 2, 2)
           .setThresholds(thresholds)
    -    assert(testModel.friendlyPredict(Vectors.dense(Array(1.0, 1.0))) === 
1.0)
    -    assert(testModel.friendlyPredict(Vectors.dense(Array(1.0, 0.2))) === 
0.0)
    +    assert(testModel.friendlyPredict(1.0, 1.0) === 1.0)
    +    assert(testModel.friendlyPredict(1.0, 0.2) === 0.0)
       }
     
       test("test thresholding not required") {
         val testModel = new TestProbabilisticClassificationModel("myuid", 2, 2)
    -    assert(testModel.friendlyPredict(Vectors.dense(Array(1.0, 2.0))) === 
1.0)
    +    assert(testModel.friendlyPredict(1.0, 2.0) === 1.0)
    +  }
    +
    +  test("test tiebreak") {
    +    val testModel = new TestProbabilisticClassificationModel("myuid", 2, 2)
    +      .setThresholds(Array(0.4, 0.4))
    +    assert(testModel.friendlyPredict(0.6, 0.6) === 0.0)
    +  }
    +
    +  test("bad thresholds") {
    +    intercept[IllegalArgumentException] {
    +      new TestProbabilisticClassificationModel("myuid", 2, 
2).setThresholds(Array(0.0, 0.1))
    +    }
    +    intercept[IllegalArgumentException] {
    +      new TestProbabilisticClassificationModel("myuid", 2, 
2).setThresholds(Array(0.0, 0.0))
    +    }
       }
    --- End diff --
    
    My apologies for not thinking of this earlier, maybe we should test 
negative as well, while we're here.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to