zhengruifeng commented on code in PR #36920:
URL: https://github.com/apache/spark/pull/36920#discussion_r901346286


##########
mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala:
##########
@@ -70,9 +62,14 @@ class RankingMetrics[T: ClassTag] @Since("3.4.0") (
   @Since("1.2.0")
   def precisionAt(k: Int): Double = {
     require(k > 0, "ranking position k should be positive")
-    predictionAndLabels.map { case (pred, lab, _) =>
-      countRelevantItemRatio(pred, lab, k, k)
-    }.mean()
+    predictionAndLabels

Review Comment:
   I think we may create a private rdd, and than use it internally to minimize 
changes.
   
   something like this:
   ```
   private val rdd = predictionAndLabels.map {
       case (pred: Array[T], lab: Array[T]) => ...
       case (pred: Array[T], lab: Array[T], rel: Array[Double]) => ...
   }
   
   ```



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to