1

It is pretty easy to normalize vectors in Scala (scala.collection.immutable.Vector) using map:

val w = Vector(3,4,5)
/** L1 norm: **/
val w_normalized = w.map { _/w.sum }

But you can't perform the same thing with org.apache.spark.mllib.linalg.Vector: if you try it, you get an error:

error: value map is not a member of org.apache.spark.mllib.linalg.Vector

So, what is a way to normalize spark vectors?

fremorie
  • 713
  • 2
  • 9
  • 20

0 Answers0