spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sethah <...@git.apache.org>
Subject [GitHub] spark pull request #15149: [SPARK-17057] [ML] ProbabilisticClassifierModels'...
Date Tue, 20 Sep 2016 14:46:07 GMT
Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15149#discussion_r79628242
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/classification/ProbabilisticClassifier.scala
---
    @@ -200,26 +200,9 @@ abstract class ProbabilisticClassificationModel[
         if (!isDefined(thresholds)) {
           probability.argmax
         } else {
    -      val thresholds: Array[Double] = getThresholds
    -      val probabilities = probability.toArray
    -      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
    -          argMax = i
    -        } else {
    -          val scaled = probabilities(i) / thresholds(i)
    -          if (scaled > max) {
    -            max = scaled
    -            argMax = i
    -          }
    -        }
    -        i += 1
    -      }
    -      argMax
    +      // If set, thresholds are known to be > 0
    +      val scaledProbability = probability.toArray.zip(getThresholds).map { case (p, t)
=> p / t }
    --- End diff --
    
    Why change from the while loop?


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

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


Mime
View raw message