April 2017
Intermediate to advanced
532 pages
12h 39m
English
Spark MLlib uses Breeze and JBlas for internal linear algebraic operations. It uses its own class to represent a vector defined using the org.apache.spark.mllib.linalg.Vector factory. A local vector has integer-typed and 0-based indices. Its values are stored as double-typed. A local vector is stored on a single machine, and cannot be distributed. Spark MLlib supports two types of local vectors, dense and sparse, created using factory methods.
The following code snippet shows how to create basic sparse and dense vectors in Spark:
val dVectorOne: Vector = Vectors.dense(1.0, 0.0, 2.0) println("dVectorOne:" + dVectorOne) // Sparse vector (1.0, 0.0, 2.0, 3.0) // corresponding to nonzero entries. val sVectorOne: Vector = Vectors.sparse(4, ...Read now
Unlock full access