Spark internally uses Breeze library linear algebra operations. Use operations and structures from here instead of importing breeze. Also, the feature map requires the output to be a breeze Vector. Change this to Spark's Vector.