ModelOriented / DALEXtra

Extensions for the DALEX package
https://ModelOriented.github.io/DALEXtra/
65 stars 10 forks source link

H2O multiclass error #86

Closed ditopcu closed 3 months ago

ditopcu commented 1 year ago

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 commented 1 year ago

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 commented 10 months ago

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