Building a classification model using H2O RandomForest

H2O provides multiple algorithms for building classification models. In this chapter, we will focus on tree ensembles again, but we are going to demonstrate their usage in the context of our sensor data problem.

We have already prepared data which we can use directly to build the H2O RandomForest model. To transfer it them into H2O format we need to create H2OContext and then call the corresponding transformation:

import org.apache.spark.h2o._ val h2oContext = H2OContext.getOrCreate(sc) val trainHF = h2oContext.asH2OFrame(trainingData, "trainHF") trainHF.setNames(columnNames) trainHF.update() val testHF = h2oContext.asH2OFrame(testData, "testHF") testHF.setNames(columnNames) testHF.update() ...

Get Mastering Machine Learning with Spark 2.x 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.