【问题标题】:Plot ROC curve of H2O in Python (one and multiple curves)在 Python 中绘制 H2O 的 ROC 曲线(一条和多条曲线)
【发布时间】:2018-11-09 00:54:19
【问题描述】:

我在 python 中使用 H2O 来制作广义线性模型,二元分类问题,我使用了这个模型

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 )

现在我想绘制模型的ROC曲线,我该怎么做?

我还想绘制多条 ROC 曲线进行比较

这是 R 中的问题,How to directly plot ROC of h2o model object in R,我如何在 python 中做到这一点?

【问题讨论】:

    标签: python python-3.x h2o glm roc


    【解决方案1】:

    试试这个:

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

    理论上应该可行,我现在无法验证。这将绘制“火车”集上的性能。

    【讨论】:

      【解决方案2】:

      试过了,效果很好

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

      【讨论】:

        猜你喜欢
        • 2019-02-27
        • 1970-01-01
        • 2012-12-14
        • 2017-09-11
        • 1970-01-01
        • 2012-01-01
        • 2019-09-16
        • 2019-08-31
        • 2021-03-03
        相关资源
        最近更新 更多