为什么我在 h2o AutoML 中训练的混淆矩阵只显示 10k 个总案例而不是 200k

问题描述 投票:0回答:1

我目前正在使用 h2o autoML 来训练一个关于二元分类问题的模型。我有一个火车(70% ~200k 行)、有效(10% ~30k 行)、测试(10% ~30k 行)和混合(10% ~30k 行)数据集,所有这些数据集都来自原始数据集的时间敏感拆分(约 30 万行)。

检查训练混淆矩阵时,我只看到 10k 个案例,而不是 ~200k。

我这样创建模型:

#  Create model
aml = H2OAutoML(
    max_runtime_secs=max_runtime_secs,
    stopping_metric=stopping_metric, # "AUCPR"
    sort_metric=sort_metric, # "AUCPR"
    nfolds=nfolds, # set to 0
    distribution=distribution, # "bernoulli"
    verbosity=verbosity,
    balance_classes=balance_classes, # False
    seed=seed,
)

aml.train(
    y=outcome_column,
    training_frame=train,
    validation_frame=valid,
    leaderboard_frame=test,
    blending_frame=blend,
)

# Get the best model
best_model = aml.get_best_model()

# get the performance on test
performance = best_model.model_performance(test)

# define the threshold based on the desired metric
best_threshold = best_model.find_threshold_by_max_metric(
        metric=metric_to_use, valid=True)

# inspect confusion matrix on training set using that threshold
train_confusion = best_model.confusion_matrix(
        thresholds=best_threshold, train=True)

# inspect confusion matrix on test using that threshold
test_confusion = performance.confusion_matrix(thresholds=best_threshold)

# confusion matrix validation using that threshold
valid_confusion = best_model.confusion_matrix(
    thresholds=best_threshold, valid=True)
)

这些是由此产生的混淆矩阵:

confusion matrix train: Confusion Matrix (Act/Pred) @ threshold = 0.35701837501784456
       False    True    Error    Rate
-----  -------  ------  -------  --------------
False  8589     190     0.0216   (190.0/8779.0)
True   272      904     0.2313   (272.0/1176.0)
Total  8861     1094    0.0464   (462.0/9955.0) 

confusion matrix valid: Confusion Matrix (Act/Pred) @ threshold = 0.3555305434918455
       False    True    Error    Rate
-----  -------  ------  -------  ----------------
False  23367    802     0.0332   (802.0/24169.0)
True   1486     1580    0.4847   (1486.0/3066.0)
Total  24853    2382    0.084    (2288.0/27235.0) 

confusion matrix test: Confusion Matrix (Act/Pred) @ threshold = 0.3546996890950105
       False    True    Error    Rate
-----  -------  ------  -------  ----------------
False  23399    769     0.0318   (769.0/24168.0)
True   1537     1529    0.5013   (1537.0/3066.0)
Total  24936    2298    0.0847   (2306.0/27234.0) 

我们可以看到,在有效和测试混淆矩阵上,我有大约 30k 个总案例,但我在火车混淆矩阵上只有大约 10k 个案例,而不是最初的 ~200k 行。为什么?

python machine-learning h2o automl h2o.ai
1个回答
0
投票

您能否提供更多细节 - 什么样的模型是最好的模型?是深度学习吗?

如果是 DeepLearning 模型,有一个参数

score_training_samples
默认为 10 000,它通过仅在样本上计算训练分数来加速训练——其背后的基本原理是用户通常不太关心训练性能指标,因此在提供加速的同时,对样本的估计通常是足够的。

您可以使用

best_model.confusion_matrix(training_frame)
获得整个训练框架的混淆矩阵。 文档中有更多详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.