Description
In Mahout scala bindings, instead of writing
val res = drmX.mapBlock(drmX.ncol) {
case (keys, block) => {
val copy = block.like
copy := block.map(row => (row - mean) / std)
(keys, copy)
}
}
I would like to be able to write
val res = drmX.mapBlock(drmX.ncol) {
case (keys, block) => {
keys -> block.map(row => (row - mean) / std)
}
}
Solution: add a method for implicit conversion from iterable to Matrix:
implicit def iterable2Matrix(that: Iterable[Vector]): Matrix = { val first = that.head val nrow = that.size val ncol = first.size val m = if (first.isDense) { new DenseMatrix(nrow, ncol) } else { new SparseRowMatrix(nrow, ncol) } that.zipWithIndex.foreach { case (row, idx) => m.assignRow(idx.toInt, row) } m }
If it sounds nice, I can send a pull request with this implemented