How to do it...

  1. Start a new project in IntelliJ or in an IDE of your choice. Make sure that the necessary JAR files are included.
  2. Set up the package location where the program will reside:
package spark.ml.cookbook.chapter2
  1.  Import the necessary packages for vector and matrix manipulation:
import org.apache.spark.mllib.linalg.distributed.RowMatriximport org.apache.spark.mllib.linalg.distributed.{IndexedRow, IndexedRowMatrix}import org.apache.spark.mllib.linalg.distributed.{CoordinateMatrix, MatrixEntry}import org.apache.spark.sql.{SparkSession}import org.apache.spark.rdd._import org.apache.spark.mllib.linalg._import breeze.linalg.{DenseVector => BreezeVector}import Array._import org.apache.spark.mllib.linalg.DenseMatriximport org.apache.spark.mllib.linalg.SparseVector ...

Get Apache Spark 2.x Machine Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.