Hi @nopenope, I finally got it to work just this morning! There are several things I had to do (note I’m using the .zip submission and R).
Here is the load_model
function that works for me:
load_model <- function(model_path){
# Load a saved trained model from the file `trained_model.RData`.
# This is called by the server to evaluate your submission on hidden data.
# Only modify this *if* you modified save_model.
#load(model_path)
model <- h2o.import_mojo(model_path)
return(model)
}
I’m also using this save_model
function and I think it works but not sure if it has been necessary with the zip submission method:
save_model <- function(model, output_path){
# Saves this trained model to a file.
# This is used to save the model after training, so that it can be used for prediction later.
# Do not touch this unless necessary (if you need specific features). If you do, do not
# forget to update the load_model method to be compatible.
# Save in `trained_model.RData`.
#save(model, file=output_path)
MODEL_OUTPUT_PATH <<- h2o.save_mojo(model, path = output_path, force = TRUE)
print(MODEL_OUTPUT_PATH)
}
In the preprocess_X_data
make sure you’re converting your x_raw
to an h2o frame.
In fit_model
I needed to use this:
y_raw <- as.h2o(y_raw)
train <- h2o.cbind(x_clean, y_raw)
Within predict.R
change model_output_path
from a hard-coded value to the mojo file you’ve saved in your submission folder.
Last step, in predict.R
, you need to convert the h2o from to a data.frame
before writing the table. I used this approach:
if(Sys.getenv('WEEKLY_EVALUATION', 'false') == 'true') {
prices = predict_premium(trained_model, Xraw)
prices = as.data.frame(prices)
write.table(x = prices, file = output_claims_file, row.names = FALSE, col.names=FALSE, sep = ",")
} else {
claims = predict_expected_claim(trained_model, Xraw)
claims = as.data.frame(claims)
write.table(x = claims, file = output_prices_file, row.names = FALSE, col.names=FALSE, sep = ",")
}