Skip to main content

`plug_values`

  • Available in: GLM, GAM, HGLM, ANOVAGLM, ModelSelection
  • Hyperparameter: yes

Description​

When missing_values_handling="PlugValues", this option is used to specify a frame containing values that will be used to impute missing values. Whereas other options mean-impute rows or skip them entirely, plug values allow you to specify values of your own choosing in the form of a single row frame that contains the desired value.

Example​

library(h2o)
h2o.init()

# import the cars dataset:
cars <- h2o.importFile("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
cars$name <- NULL

# create an H2O frame using the mean of the cars dataset
means <- h2o.mean(cars, na.rm = TRUE, return_frame = TRUE)

# train GLM models, configuring plug_values in the second
glm1 <- h2o.glm(training_frame = cars, y = "cylinders")
glm2 <- h2o.glm(training_frame = cars,
y = "cylinders",
missing_values_handling = "PlugValues",
plug_values = means)

# determine if the coefficients are equal
h2o.coef(glm1)
Intercept economy displacement power weight
2.8316269982 0.0043748133 0.0141242460 -0.0030047140 0.0001410077
acceleration year economy_20mpg
-0.0146035179 0.0017987846 -0.3754994243

h2o.coef(glm2)
Intercept economy displacement power weight
2.8316269982 0.0043748133 0.0141242460 -0.0030047140 0.0001410077
acceleration year economy_20mpg
-0.0146035179 0.0017987846 -0.3754994243

Feedback