DALEXtra icon indicating copy to clipboard operation
DALEXtra copied to clipboard

H2O multiclass error

Open ditopcu opened this issue 2 years ago • 2 comments

Hello,

I am not sure if this is an error but when I am using -following- default yhat function

` "H2OMultinomialModel" = { if (!inherits(newdata, "H2OFrame")) { newdata <- h2o::as.h2o(newdata) } ret <- as.data.frame(h2o::h2o.predict(X.model, newdata = newdata)) colnames(ret) <- normalize_h2o_names(colnames(ret))

  if (!is.null(attr(X.model, "predict_function_target_column"))) {
    return(ret[,attr(X.model, "predict_function_target_column")])
  }

  ret[,-1]

}`

With this prediction function, predict_parts function gives an error related to dimensions.

So I checked yhatranger source code which returns a matrix. So I made the following custom yhat function, and now predict_parts works normally.

`new_custom <- function(X.model, newdata) {

if (!inherits(newdata, "H2OFrame")) {
  newdata <- h2o::as.h2o(newdata)
}
ret <- as.data.frame(h2o::h2o.predict(X.model, newdata = newdata))
colnames(ret) <- normalize_h2o_names(colnames(ret))

if (!is.null(attr(X.model, "predict_function_target_column"))) {
  return( **as.matrix(**ret[,attr(X.model, "predict_function_target_column")]))
}

**as.matrix**(ret[,-1])

}`

ditopcu avatar Dec 30 '22 12:12 ditopcu

Hi,

thanks for letting me know about potential issues! Could you please show me a reproducible example (possibly on some dummy date) so I could explore this myself? Would like to check what exactly went wrong

maksymiuks avatar Dec 31 '22 12:12 maksymiuks

Facing this issue. @ditopcu can you please give a complete solution please or a PR maybe ?

boral avatar Nov 13 '23 20:11 boral