zhengruifeng commented on a change in pull request #27944: [SPARK-31180][ML]
Implement PowerTransform
URL: https://github.com/apache/spark/pull/27944#discussion_r401523780
##########
File path: mllib/src/main/scala/org/apache/spark/mllib/util/MLUtils.scala
##########
@@ -554,4 +554,46 @@ object MLUtils extends Logging {
math.log1p(math.exp(x))
}
}
+
+ /**
+ * Sequentially group input elements to groups, and do aggregation within
each group.
+ * A group only contains single key, and be of size no greater than the
corresponding size.
+ * For example, input keys = [1, 1, 1, 2, 2, 2, 3, 3, 1],
+ * group sizes are: 1->2, 2->5, 3->1,
+ * then the groups are {1, 1}, {1}, {2, 2, 2}, {3}, {3}, {1}.
+ *
+ * @param input input iterator containing (key, value), usually sorted by key
+ * @param getSize group size of each key.
+ * @return aggregated iterator
+ */
+ private[spark] def combineWithinGroups[K, V, U](
Review comment:
This method should be helpful when implementing algorithms which needs
down-sampling, it is similar to down-sampling in AUC (only one column) while it
can be used in multi-column cases with variant group sizes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]