Github user mahmoudmahdi24 commented on a diff in the pull request: https://github.com/apache/spark/pull/21120#discussion_r199119223 --- Diff: mllib/src/main/scala/org/apache/spark/ml/stat/Summarizer.scala --- @@ -562,6 +573,23 @@ private[ml] object SummaryBuilderImpl extends Logging { Vectors.dense(currL1) } + + /** + * Sum of each dimension + */ + def sum: Vector = { + require(requestedMetrics.contains(Sum)) + require(totalWeightSum > 0, s"Nothing has been added to this summarizer.") + + val realSum = Array.ofDim[Double](n) + var i = 0 + val len = currMean.length + while (i < len) { + realSum(i) = currMean(i) * weightSum(i) + i += 1 --- End diff -- Please avoid using mutable values, use foldLeft for example to solve this.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org