How to directly plot ROC of h2o model object in R

后端 未结 4 1563
灰色年华
灰色年华 2021-01-06 00:33

My apologies if I\'m missing something obvious. I\'ve been thoroughly enjoying working with h2o in the last few days using R interface. I would like to evaluate my model, sa

4条回答
  •  悲&欢浪女
    2021-01-06 01:20

    you can get the roc curve by passing the model performance metrics to H2O's plot function.

    shortened code snippet which assumes you created a model, call it glm, and split your dataset into train and validation sets:

    perf <- h2o.performance(glm, newdata = validation)
    h2o.plot(perf)
    

    full code snippet below:

    h2o.init()
    
    # Run GLM of CAPSULE ~ AGE + RACE + PSA + DCAPS
    prostatePath = system.file("extdata", "prostate.csv", package = "h2o")
    prostate.hex = h2o.importFile(path = prostatePath, destination_frame = "prostate.hex")
    glm = h2o.glm(y = "CAPSULE", x = c("AGE","RACE","PSA","DCAPS"), training_frame = prostate.hex, family = "binomial", nfolds = 0, alpha = 0.5, lambda_search = FALSE)
    
    perf <- h2o.performance(glm, newdata = prostate.hex)
    h2o.plot(perf)
    

    and this will produce the following:

提交回复
热议问题