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

Imported MOJO produces different predictions than the original model #8303

Closed
exalate-issue-sync bot opened this issue May 11, 2023 · 1 comment
Closed

Comments

@exalate-issue-sync
Copy link

A customer reports that for a binary classification problem the threshold applied to binarize the predictions is different between the actual model (the threshold is then whatever value maximises the F1) and MOJO (when the threshold appears to be just 0.5). I was able to reproduce this on 3.28.0.4:

{code:r}
library(tidyverse)
library(h2o)
h2o.init()
cc <- read_csv('~/Downloads/creditcard_train_cat.csv')
cc_h2o <- as.h2o(cc)
cc_h2o['DEFAULT_PAYMENT_NEXT_MONTH'] = h2o.asfactor(cc_h2o['DEFAULT_PAYMENT_NEXT_MONTH'])
drf <- h2o.randomForest(y = 'DEFAULT_PAYMENT_NEXT_MONTH', training_frame = cc_h2o)
dir <- '/Users/vaclav/Downloads/'
mojo_file <- h2o.download_mojo(drf, dir)
mojo <- h2o.import_mojo(paste0(dir, mojo_file))
pred_h2o <- predict(drf, cc_h2o)
pred_mojo <- predict(mojo, cc_h2o)
all(pred_h2o$p0 == pred_mojo$p0) # TRUE
all(pred_h2o$predict == pred_mojo$predict) # FALSE! <- the thresholds must differ
pred_h2o$predict_mojo <- pred_mojo$predict
pred_df <- as.data.frame(pred_h2o)
max(filter(pred_df, predict == 1)$p0)
[1] 0.7108447
max(filter(pred_df, predict_mojo == 1)$p0)
[1] 0.499601
{code}

@h2o-ops
Copy link
Collaborator

h2o-ops commented May 14, 2023

JIRA Issue Migration Info

Jira Issue: PUBDEV-7334
Assignee: Michal Kurka
Reporter: Vaclav
State: Resolved
Fix Version: 3.28.1.1
Attachments: N/A
Development PRs: Available

Linked PRs from JIRA

#4371

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

No branches or pull requests

1 participant