spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neggert <...@git.apache.org>
Subject [GitHub] spark pull request #15018: [SPARK-17455][MLlib] Improve PAVA implementation ...
Date Wed, 14 Dec 2016 16:16:15 GMT
Github user neggert commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15018#discussion_r92428442
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala
---
    @@ -344,27 +344,30 @@ class IsotonicRegression private (private var isotonic: Boolean)
extends Seriali
         }
     
         var i = 0
    -    val len = input.length
    -    while (i < len) {
    -      var j = i
    -
    -      // Find monotonicity violating sequence, if any.
    -      while (j < len - 1 && input(j)._1 > input(j + 1)._1) {
    -        j = j + 1
    -      }
    +    val n = input.length - 1
    +    var notFinished = true
    +
    +    while (notFinished) {
    +      i = 0
    +      notFinished = false
    +
    +      // Iterate through the data, fix any monotonicity violations we find
    +      // We may need to do this multiple times, as pooling can introduce violations
    +      // at locations that were previously fine.
    +      while (i < n) {
    +        var j = i
    +
    +        // Find next monotonicity violating sequence, if any.
    +        while (j < n && input(j)._1 >= input(j + 1)._1) {
    +          j = j + 1
    +        }
     
    -      // If monotonicity was not violated, move to next data point.
    -      if (i == j) {
    -        i = i + 1
    -      } else {
    -        // Otherwise pool the violating sequence
    -        // and check if pooling caused monotonicity violation in previously processed
points.
    -        while (i >= 0 && input(i)._1 > input(i + 1)._1) {
    +        // Pool the violating sequence with the data point preceding it
    +        if (input(i)._1 != input(j)._1) {
    --- End diff --
    
    Correct. Any violations that are introduced will be fixed in the next iteration.


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