Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H2O multiclass error #86

Closed
ditopcu opened this issue Dec 30, 2022 · 2 comments
Closed

H2O multiclass error #86

ditopcu opened this issue Dec 30, 2022 · 2 comments

Comments

@ditopcu
Copy link

ditopcu commented Dec 30, 2022

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])

}`

@maksymiuks
Copy link
Member

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

@boral
Copy link

boral commented Nov 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants