2) Process Random Data Frame against Neural Network Model

This Blog entry is from the Monte Carlo Model section in Learn R.

The data frame can be used with all of the machine learning algorithms presented in this guide thus far, although to use the data frame with H2O, it needs to be loaded into H2O as hex:

To load the data frame into H2O use:

SimulatedHex <- as.h2o(SimulatedDataFrame)
1.png

Run the line of script to console:

2.png

As before, use the H2O predict function to execute the model, passing the simulated dataframe in the place of real data:

SimulatedScores <- h2o.predict(Model,SimulatedHex)
3.png

Parse the Activation to a standalone vector:

SimulatedActvations <- as.vector(SimulatedScores[1])
4.png

Run the line of script to console:

5.png

Append the vector to the simulations data frame (keeping in mind that dplyr is already loaded):

SimulatedDataFrame <-mutate(SimulatedDataFrame, SimulatedActvations)
6.png

Run the line of script to console:

7.png

Viewing the simulated data frame, scrolling to the last column:

View(SimulatedDataFrame)
8.png

It can be seen that the simulated dataframe has been passed through the H2O neural network as if it were production data.  The last column contains the predicted activation, in this case fraud prevention.  This data frame can now be used to describe the most likely scenario surrounding an activation.