Custom R Script for H2O Autoencoder

I am using the Turbofan Engine Degradation Simulation Data Set from NASA located here:

https://ti.arc.nasa.gov/tech/dash/groups/pcoe/prognostic-data-repository/#turbofan

I am trying to remove noise from the sensor data by applying the H2O autoencoder, as recommended here:

I have followed these instructions to get H2o installed and setup in Exploratory:

https://blog.exploratory.io/using-h2o-powered-machine-learning-algorithms-in-r-exploratory-9c514fddca8d

I created a custom script, which runs, but the data I return is not in the correct format for Exploratory, and I get the resulting error:

Please define tidy.Problem with mutate() input model. :heavy_multiplication_x: cannot coerce class ‘structure(H2OAutoEncoderModel, package = h2o)’ :information_source: Input model is purrr::map2(...)

Below is my script and the output from H2O service.

Thanks in advance.

library(h2o)

h2o.init(max_mem_size=“60g”, nthreads=-1)

Utility function that converts regular data.frame into H2OFrame.

as_h2o ← function(df) {

Convert character columns into factor.

for (colname in colnames(df)) {
if (class(df[[colname]]) == “character”) {
df[[colname]] ← as.factor(df[[colname]])
}
}
df ← as.h2o(df)
df
}

build_h2o_autoencoder ← function(data) {

i <- 1:200
h2o_data.train <- data[i, -1]
h2o_data.train <- as_h2o(h2o_data.train)

itest <- 201:295
h2o_data.test <- data[itest, -1]
h2o_data.test <- as_h2o(h2o_data.test)

#xnames <- colnames(h2o_data.train)
xnames = c(4:25)

h2o_data <- as_h2o(data) # convert data into H2OFrame.

# Train a denoise autoencoder
denoise_ae <- h2o.deeplearning(
  x = xnames,
  training_frame = h2o_data.train,
  validation_frame = h2o_data.test,
  autoencoder = TRUE,
  hidden = 3,
  activation = 'Tanh',
  sparse = TRUE
)
# convert predicted data back to data.frame.
denoise_ae <- as.data.frame(denoise_ae)
denoise_ae

}

Partial output from the H2O service

11-20 09:07:43.577 192.168.2.16:54321 93144 FJ-1-3 INFO: Finished training the Deep Learning model.
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Model Metrics Type: AutoEncoder
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Description: N/A
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: model id: DeepLearning_model_R_1605876768431_4
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: frame id: df.temporary.sample.16.49%
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: MSE: 0.13167608
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: RMSE: 0.36287197
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Model Metrics Type: AutoEncoder
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Description: N/A
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: model id: DeepLearning_model_R_1605876768431_4
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: frame id: df
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: MSE: 0.13092372
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: RMSE: 0.36183384
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Variable Importances:
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Variable Relative Importance Scaled Importance Percentage
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 5.70 1.000000 1.000000 0.078082
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 1.01 0.895548 0.895548 0.069926
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 41.69 0.747241 0.747241 0.058346
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 445.00 0.709292 0.709292 0.055383
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 137.36 0.703748 0.703748 0.054950
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 8311.32 0.687593 0.687593 0.053689
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 100.0 0.667932 0.667932 0.052154
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 3.91 0.643408 0.643408 0.050239
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 1112.93 0.603242 0.603242 0.047103
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 8074.83 0.593626 0.593626 0.046352
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: —
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2211.86 0.508927 0.508927 0.039738
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 100.00 0.482159 0.482159 0.037648
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 549.68 0.439516 0.439516 0.034318
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 10.62 0.429863 0.429863 0.033565
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 0.02 0.411523 0.411523 0.032133
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 129.78 0.407064 0.407064 0.031784
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2212 0.390483 0.390483 0.030490
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 1343.43 0.387120 0.387120 0.030227
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 6.3670 0.272774 0.272774 0.021299
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 1 0.207339 0.207339 0.016190
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Status of Neuron Layers (auto-encoder, gaussian distribution, Quadratic loss, 164 weights/biases, 8.1 KB, 606,360 training samples, mini-batch size 1):
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Layer Units Type Dropout L1 L2 Mean Rate Rate RMS Momentum Mean Weight Weight RMS Mean Bias Bias RMS
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 1 23 Input 0.00 %
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2 3 Tanh 0 0.000000 0.000000 1.004224 0.000000 0.000000 0.016175 0.254712 0.000000 0.000000
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 3 23 Tanh 0.000000 0.000000 1.004224 0.000000 0.000000 -0.022812 0.253095 0.000000 0.000000
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Scoring History:
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: Timestamp Duration Training Speed Epochs Iterations Samples Training RMSE Training MSE Validation RMSE Validation MSE
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2020-11-20 09:07:40 0.294 sec 0.00000 obs/sec 0.00000 0 0.000000 0.36287 0.13168 0.36183 0.13092
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2020-11-20 09:07:43 3.340 sec 210468 obs/sec 10.00000 10 606360.000000 0.78124 0.61034 0.78188 0.61133
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: 2020-11-20 09:07:43 3.442 sec 210249 obs/sec 10.00000 10 606360.000000 0.36287 0.13168 0.36183 0.13092
11-20 09:07:43.579 192.168.2.16:54321 93144 FJ-1-3 INFO: ==============================================================================================================================================================================
11-20 09:07:44.369 192.168.2.16:54321 93144 #22755-14 INFO: GET /3/Models/DeepLearning_model_R_1605876768431_4, parms: {}