Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class IndexedRowMatrix(
val mat = BDM.zeros[Double](m, n)
rows.collect().foreach { case IndexedRow(rowIndex, vector) =>
val i = rowIndex.toInt
vector.toBreeze.activeIterator.foreach { case (j, v) =>
vector.foreachActive { case (j, v) =>
mat(i, j) = v
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ class RowMatrix(
val n = numCols().toInt
val mat = BDM.zeros[Double](m, n)
var i = 0
rows.collect().foreach { v =>
v.toBreeze.activeIterator.foreach { case (j, v) =>
rows.collect().foreach { vector =>
vector.foreachActive { case (j, v) =>
mat(i, j) = v
}
i += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ object MLUtils {
def saveAsLibSVMFile(data: RDD[LabeledPoint], dir: String) {
// TODO: allow to specify label precision and feature precision.
val dataStr = data.map { case LabeledPoint(label, features) =>
val featureStrings = features.toBreeze.activeIterator.map { case (i, v) =>
s"${i + 1}:$v"
val sb = new StringBuilder(label.toString)
features.foreachActive { case (i, v) =>
sb += ' '
sb ++= s"${i + 1}:$v"
}
(Iterator(label) ++ featureStrings).mkString(" ")
sb.mkString
}
dataStr.saveAsTextFile(dir)
}
Expand Down