Github user jkbradley commented on a diff in the pull request: https://github.com/apache/spark/pull/15018#discussion_r92298204 --- 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) { --- End diff -- That should be correct. Lemma 1 from "A Fast Scaling Algorithm for Minimizing Separable Convex Functions Subject to Chain Constraints"
--- 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