diff options
author | Sean Owen <sowen@cloudera.com> | 2016-04-29 09:21:27 +0200 |
---|---|---|
committer | Nick Pentreath <nickp@za.ibm.com> | 2016-04-29 09:21:27 +0200 |
commit | d1cf320105504f908ee01f33044d0a6b29c3c03f (patch) | |
tree | b2116c0a0cd1a1a8833dc2fe80b4d07e8423c2c1 /mllib/src/main/scala | |
parent | 24d07e45d4e2e5222043b9a4447aa6c384069d4f (diff) | |
download | spark-d1cf320105504f908ee01f33044d0a6b29c3c03f.tar.gz spark-d1cf320105504f908ee01f33044d0a6b29c3c03f.tar.bz2 spark-d1cf320105504f908ee01f33044d0a6b29c3c03f.zip |
[SPARK-14886][MLLIB] RankingMetrics.ndcgAt throw java.lang.ArrayIndexOutOfBoundsException
## What changes were proposed in this pull request?
Handle case where number of predictions is less than label set, k in nDCG computation
## How was this patch tested?
New unit test; existing tests
Author: Sean Owen <sowen@cloudera.com>
Closes #12756 from srowen/SPARK-14886.
Diffstat (limited to 'mllib/src/main/scala')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala b/mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala index c45742cebb..4ed4a05894 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala @@ -140,7 +140,7 @@ class RankingMetrics[T: ClassTag](predictionAndLabels: RDD[(Array[T], Array[T])] var i = 0 while (i < n) { val gain = 1.0 / math.log(i + 2) - if (labSet.contains(pred(i))) { + if (i < pred.length && labSet.contains(pred(i))) { dcg += gain } if (i < labSetSize) { |