How to parse the Vector in Spark-MLlib
This article will explain in detail how to parse the vectors in Spark-MLlib. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Matrix transpose
Vector
Spark vectors are stored in the form of objects
Vectorscala > import org.apache.spark.mllib.linalg. {Vectors,Vector} import org.apache.spark.mllib.linalg. {Vectors,Vector} scala > Vectors.dense res0: org.apache.spark.mllib.linalg.Vector = [1.0, 2.0, 3.0, breeze.linalg.DenseVector) res1: breeze.linalg.DenseVector [Int] = DenseVector, scala > res1.tres2: breeze.linalg.Transpose [breeze.linalg.DenseVectorint] = Transpose (DenseVector 4) scala > res1+res1res3: breeze.linalg.DenseVector [Int] = DenseVector (2,4,6,8) scala > res1*res1.tres4: breeze.linalg.DenseMatrix [Int] = 123 342 4 6 83 6 9 124 8 12 16 that's all for parsing vectors in Spark-MLlib. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.