Step 5 - Preparing the H2O DataFrame

Up to this point, our DataFrame (that is, t4) is in Spark DataFrame. But it cannot be consumed by the H2O model. So, we have to convert it to an H2O frame. So let's do it:

val creditcard_hf: H2OFrame = h2oContext.asH2OFrame(t4.orderBy(rand()))

We split the dataset to, say, 40% supervised training, 40% unsupervised training, and 20% test using H2O built-in splitter called FrameSplitter:

val sf = new FrameSplitter(creditcard_hf, Array(.4, .4),                 Array("train_unsupervised", "train_supervised", "test")                .map(Key.make[Frame](_)), null)water.H2O.submitTask(sf)val splits = sf.getResultval (train_unsupervised, train_supervised, test) = (splits(0), splits(1), splits(2))

In the above code segment, Key.make[Frame](_) ...

Get Scala Machine Learning Projects 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.