【问题标题】:h2o ValueError: No metric tprh2o ValueError:没有指标 tpr
【发布时间】:2017-08-12 21:39:54
【问题描述】:

当尝试使用例如获取召回分数时

rf_model.recall()

我得到错误:

h2o ValueError: No metric tpr

我可以获得其他指标,例如准确率、AUC、精度和 F1,但没有召回... 这大概是一个错误。

如果我跑步:

from h2o.model.metrics_base import H2OBinomialModelMetrics as bmm
reporter = bmm(rf_model.metric)
rf_model.metric('recall')

我明白了:

Could not find exact threshold 0.0; using closest threshold found 0.0.

发生了什么事?

我正在运行 h2o 版本“h2o-3.15.0.3990”。

我遵循了 h2o 教程:

https://github.com/h2oai/h2o-tutorials/blob/master/training/h2o_algos/src/py/decision_tree_ensembles.ipynb

使用我自己的数据集,我得到了上述错误。

有什么帮助吗?

另外,如何使用 h2o 绘制精确/召回曲线?

谢谢

【问题讨论】:

  • 请不要与邮件列表交叉发布。 (StackOverflow 是解决这类问题的更好地方。)

标签: python machine-learning h2o precision-recall


【解决方案1】:

从您的第二个问题开始,Flow 具有精确/召回曲线(并且是交互式的)。 Flow 始终在每个节点的端口 54321 上运行,即 http://127.0.0.1:54321 如果您在本地运行 h2o。

我想你的数据或模型有一些有趣的地方,当你查看精度/召回曲线时,它就会变得清晰。

在 R 中,如果您执行 str(m)(其中 m 是您的模型),您将看到所有模型数据。 m@training_metrics@metrics$thresholds_and_metric_scores$recall 保存每个阈值的召回数。

我还不知道如何查看 Python 对象的内部,但您的调用是正确的。在我的快速测试中(添加了 2 类枚举列的 iris 数据集):

m.metric("recall")

给了:

[[0.8160852636726422, 1.0]]

如果我想要所有的值,它会是这样的:

mDL.metric("recall",thresholds=[x/100.0 for x in range(1,100)])

给予:

Could not find exact threshold 0.01; using closest threshold found 0.010396965719556233.
Could not find exact threshold 0.02; using closest threshold found 0.016617060110009896.
...
Could not find exact threshold 0.92; using closest threshold found 0.9469528904679438.
Could not find exact threshold 0.93; using closest threshold found 0.9469528904679438.
Could not find exact threshold 0.94; using closest threshold found 0.9469528904679438.
Could not find exact threshold 0.95; using closest threshold found 0.9469528904679438.
Could not find exact threshold 0.96; using closest threshold found 0.9469528904679438.
Could not find exact threshold 0.97; using closest threshold found 0.9760293572153097.
Could not find exact threshold 0.98; using closest threshold found 0.9787491606489236.
Could not find exact threshold 0.99; using closest threshold found 0.9909817370067531.

[[0.01, 1.0],
 [0.02, 1.0],
 [0.03, 1.0],
 ...
 [0.87, 1.0],
 [0.88, 1.0],
 [0.89, 0.9850746268656716],
 [0.9, 0.9850746268656716],
 [0.91, 0.9850746268656716],
 [0.92, 0.9850746268656716],
 [0.93, 0.9850746268656716],
 [0.94, 0.9850746268656716],
 [0.95, 0.9850746268656716],
 [0.96, 0.9850746268656716],
 [0.97, 0.9701492537313433],
 [0.98, 0.9552238805970149],
 [0.99, 0.8955223880597015]]

(我得到了如此不寻常的输出,因为它几乎完美地学习了我的数据集 - 我怀疑这就是你所发生的事情?)(我愚蠢地让我的二进制列成为输入列之一的直接函数,没有噪音! )

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2018-07-19
    • 2019-08-08
    • 1970-01-01
    相关资源
    最近更新 更多