Skip to content

Commit

Permalink
[SPARK-4130][MLlib] Fixing libSVM parser bug with extra whitespace
Browse files Browse the repository at this point in the history
This simple patch filters out extra whitespace entries.

Author: Joseph E. Gonzalez <[email protected]>
Author: Joey <[email protected]>

Closes #2996 from jegonzal/loadLibSVM and squashes the following commits:

e0227ab [Joey] improving readability
e028e84 [Joseph E. Gonzalez] fixing whitespace bug in loadLibSVMFile when parsing libSVM files
  • Loading branch information
jegonzal authored and mengxr committed Oct 30, 2014
1 parent 6db3157 commit c7ad085
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object MLUtils {
.map { line =>
val items = line.split(' ')
val label = items.head.toDouble
val (indices, values) = items.tail.map { item =>
val (indices, values) = items.tail.filter(_.nonEmpty).map { item =>
val indexAndValue = item.split(':')
val index = indexAndValue(0).toInt - 1 // Convert 1-based indices to 0-based.
val value = indexAndValue(1).toDouble
Expand Down

0 comments on commit c7ad085

Please sign in to comment.