How to do it...

  1. Start the Spark shell:
        $ spark-shell
  1. Import the MLlib vector explicitly (not to be confused with other vector classes in collections):
        scala> import org.apache.spark.ml.linalg.{Vector, Vectors}
  1. Create a dense vector:
        scala> val denseHouse = Vectors.dense(4500d,41000d,4d)
  1. Create a sparse vector:
        scala> val sparseHouse =
Vectors.sparse(3,Array(0,1,2),Array(4500d,41000d,4d))
  1. 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.
Reset