[SPARK-2515][mllib] Chi Squared test

This could be done in a single pass (or in batches if numCols is large):

~~~
data.flatMap { p =>
  // assume dense vectors
  p.features.toArray.view.zipWithIndex { case (f, j) =>
    (j, p, f)
  }
}.countByValue()
~~~