# spark-reviews mailing list archives

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

https://github.com/apache/spark/pull/15018#discussion_r92331409

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

I think the original one i.e., `input(j)._1 > input(j + 1)._1` is correct. Here it
is going to select out-of-order blocks.

Quoted from the paper:
> We refer to two blocks [p, q] and [q + 1, r] as consecutive. We refer to two consecutive
blocks [p, q] and [q +1, r] as in-order if  theta_pq <= theta_q+1, r and out-of-order otherwise.

LEMMA 1 is pointing the how a merged block is also a single-valued block.

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