- Start the Spark shell:
$ spark-shell
- Import the MLlib vector explicitly (not to be confused with other vector classes in collections):
scala> import org.apache.spark.ml.linalg.{Vector, Vectors}
- Create a dense vector:
scala> val denseHouse = Vectors.dense(4500d,41000d,4d)
- Create a sparse vector:
scala> val sparseHouse =
Vectors.sparse(3,Array(0,1,2),Array(4500d,41000d,4d))
- Create a vector of all zeroes:
scala> val zeroes = Vectors.zeros(3)
..................Content has been hidden....................
You can't read the all page of ebook, please click
here login for view all page.