I am deploying a model using the H2O package with R on an Azure Machine Learning Studio notebook.
I understand that when requesting my predict function the data goes in json format, and when the as.h2o () command inside the mypred function tries to convert json to h2o format it can't and occurs an error
Train the model
logistica_h2o <- h2o.glm(x = X, y = Y,
training_frame = treino.h2o,
family = "binomial)
get workspace ID and token and
workspace_id <- ""
authorization_token <- ""
ws <- workspace(workspace_id, authorization_token)
create my predict function
newdata <- dados[,-32] #Remove response variable
mypredict <- function(newdata){
library(h2o)
newdata <- as.h2o(newdata)
as.data.frame(h2o.predict(logistica_h2o, newdata))
}
here I publish the service
ep <- publishWebService(ws = ws,
fun = mypredict,
name = "PredicaoDeEntradaDeRonda",
inputSchema = dados[,-32],
data.frame=T)
The problems occurs here
ewdata <-treino.h2o[1,-32]
pred <- consume(ep, newdata)
Error: No method asJSON S3 class: H2OFrame Traceback:
consume(ep, newdata)
callAPI(apiKey, requestUrl, requestsLists, globalParam, retryDelay, . .retry = .retry)
charToRaw(paste(toJSON(req, auto_unbox = TRUE, digits = 16), . collapse = "\n"))
paste(toJSON(req, auto_unbox = TRUE, digits = 16), collapse = "\n")
toJSON(req, auto_unbox = TRUE, digits = 16)
asJSON(x, dataframe = dataframe, Date = Date, POSIXt = POSIXt, . factor = factor, complex = complex, raw = raw, matrix = matrix, . auto_unbox = auto_unbox, digits = digits, na = na, null = null, . force = force, indent = indent, ...)
asJSON(x, dataframe = dataframe, Date = Date, POSIXt = POSIXt,