Skip to content

Commit 5bd1f9a

Browse files
committed
add require for one-based in loadLIBSVM
1 parent 97a60cf commit 5bd1f9a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mllib/src/main/scala/org/apache/spark/mllib/util/MLUtils.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ object MLUtils {
8282
val value = indexAndValue(1).toDouble
8383
(index, value)
8484
}.unzip
85+
require(indices.size == 0 || indices(0) >= 0,
86+
"indices should be one-based in LIBSVM format")
8587
(label, indices.toArray, values.toArray)
8688
}
8789

0 commit comments

Comments
 (0)