Joe
Joe

Reputation: 601

Plot ROC curve of H2O in Python (one and multiple curves)

I am using H2O in python to make a Generalized Linear Model, binary classification problem, I made the model using

glm_fit_lambda_search = H2OGeneralizedLinearEstimator( family='binomial', 
                                      model_id='glm_fit_lambda_search', 
                                      lambda_search=True )

glm_fit_lambda_search.train( x = x, 
                         y = y, 
                         training_frame = trainH2O, 
                         validation_frame = testH2O )

Now I want to plot the ROC curve of the model, how can I do that?

Also I want to plot multiple ROC curves for comparison

Here is the question in R, How to directly plot ROC of h2o model object in R, How can I do this in python?

Upvotes: 1

Views: 2374

Answers (2)

Joe
Joe

Reputation: 601

Tried this and it worked

out = glm_fit_lambda_search.model_performance(testH2O)
fpr = out.fprs
tpr = out.tprs

import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve, auc

plt.figure()
lw = 2
plt.plot(fpr, tpr, color='blue', lw=lw, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], color='red', lw=lw, linestyle='--')
plt.xlim([0.0, 1.05])
plt.ylim([0.0, 1.05])
plt.legend(loc="lower right")
plt.show()

Upvotes: 3

Karl
Karl

Reputation: 5822

try this:

performace = glm_fit_lambda_search.model_performance(train=True)
performace.plot()

should work in theory, I'm not able to verify right now. This will plot the performance on the "train" set.

Upvotes: 4

Related Questions