How it works...

In this example, we demonstrated usage of the One-vs-Rest classifier. We began by loading the classic Iris dataset in libsvm format. Next, we split the dataset with a ratio of 80% for a training dataset and 20% for a test dataset. We draw the users' attention to how we use system time for randomness in a split as follows:

data.randomSplit(Array( 0.8 , 0.2 ), seed = System.currentTimeMillis())

The algorithm can be best described as a three-step process:

  1. We first configure the regression object without having to have a base logistic model at hand so it can be fed into our classifier:
LogisticRegression().setMaxIter(15).setTol(1E-3).setFitIntercept(true)
  1. In the next step, we feed the configured regression model into our classifier ...

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.