开始使用免费开始使用

修改阈值

在视频中,您了解了 NannyML 如何计算阈值,并学习了如何根据您的场景进行自定义。

在本练习中,您的任务是定义两个自定义的标准差阈值和常量阈值,然后将它们应用到针对 US Census 数据集的 CBPE 算法结果上。

参考集与分析集已分别预加载为 referenceanalysisnannyml 库也已导入。

本练习是课程的一部分

Python 中的机器学习监控

查看课程

练习说明

  • nannyml.thresholds 导入 ConstantThresholdStandardDeviationThreshold
  • 初始化标准差方法,并将 std_lower_multiplierstd_upper_multiplier 参数设为 2
  • 初始化常量阈值方法,将下界参数设为 0.9,上界设为 0.98
  • 将常量阈值方法用于 f1 指标,将标准差方法用于 accuracy 指标,并传递给 CBPE 算法。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import custom thresholds
from ____.____ import ____, ____

# Initialize custom thresholds
stdt = ____(____=____, ____=____)
ct = ____(____=____, ____=____)

# Initialize the CBPE algorithm
estimator = nannyml.CBPE(
    problem_type='classification_binary',
    y_pred_proba='predicted_probability',
    y_pred='prediction',
    y_true='employed',
    metrics=['roc_auc', 'accuracy', 'f1'],
    thresholds={____: ____, ____: ____})
编辑并运行代码