【问题标题】:Classification Scores differ between H2O4GPU and Scikit-LearnH2O4GPU 和 Scikit-Learn 的分类分数不同
【发布时间】:2019-04-16 20:28:49
【问题描述】:

我已经开始使用精度和召回率来评估随机森林分类器。然而,尽管分类器的 CPU 和 GPU 实现的训练集和测试集相同,但我看到返回的评估分数存在差异。这是库中的一个已知错误吗?

以下两个代码示例供参考。

Scikit-Learn (CPU)

from sklearn.metrics import recall_score, precision_score
from sklearn.ensemble import RandomForestClassifier

rf_cpu = RandomForestClassifier(n_estimators=5000, n_jobs=-1)
rf_cpu.fit(X_train, y_train)
rf_cpu_pred = clf.predict(X_test)

recall_score(rf_cpu_pred, y_test)
precision_score(rf_cpu_pred, y_test)

CPU Recall: 0.807186
CPU Precision: 0.82095

H2O4GPU(GPU)

from h2o4gpu.metrics import recall_score, precision_score
from h2o4gpu import RandomForestClassifier

rf_gpu = RandomForestClassifier(n_estimators=5000, n_gpus=1)
rf_gpu.fit(X_train, y_train)
rf_gpu_pred = clf.predict(X_test)

recall_score(rf_gpu_pred, y_test)
precision_score(rf_gpu_pred, y_test)

GPU Recall: 0.714286
GPU Precision: 0.809988

【问题讨论】:

    标签: python scikit-learn random-forest h2o h2o4gpu


    【解决方案1】:

    更正:意识到精度和召回率的输入顺序错误。根据 Scikit-Learn documentation,订单始终为 (y_true, y_pred)

    更正的评估代码

    recall_score(y_test, rf_gpu_pred)
    precision_score(y_test, rf_gpu_pred)
    

    【讨论】:

    • 这是否改变了值/结果?
    • @AndreasMueller 它确实做到了......无论出于何种原因,Scikit-Learn 的数字现在要低得多(精度 ~0.6,召回 ~0.6)。 H2O4GPU 数量略高。
    • 您可以尝试两次使用相同的评分函数来确定吗?但我想主要区别在于超参数。
    猜你喜欢
    • 2021-02-15
    • 2018-01-27
    • 2016-05-22
    • 2016-04-22
    • 2014-06-19
    • 2018-01-18
    • 1970-01-01
    • 2016-10-17
    • 2018-07-03
    相关资源
    最近更新 更多