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

    https://github.com/apache/spark/pull/15149#discussion_r80069407
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/ProbabilisticClassifier.scala
 ---
    @@ -200,22 +200,17 @@ abstract class ProbabilisticClassificationModel[
         if (!isDefined(thresholds)) {
           probability.argmax
         } else {
    -      val thresholds: Array[Double] = getThresholds
    -      val probabilities = probability.toArray
    +      val thresholds = getThresholds
           var argMax = 0
           var max = Double.NegativeInfinity
           var i = 0
           val probabilitySize = probability.size
           while (i < probabilitySize) {
    -        if (thresholds(i) == 0.0) {
    -          max = Double.PositiveInfinity
    +        // thresholds are all > 0, excepting that at most one may be 0
    +        val scaled = probability(i) / thresholds(i)
    +        if (scaled > max) {
    --- End diff --
    
    I actually meant what is the correct answer when they are both zero. 
Essentially saying "never predict this class" and "always predict this class" 
at the same time. I figured we would just predict the class with zero threshold 
regardless of the probability, but it seems currently it's the opposite. We 
give the probability higher precedence. 
    
    BTW, it is valid to have only one class.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to