开始使用免费开始使用

不可靠数据源识别

您的团队正在开发一个模型,用于协助汽车安全行业生成准确的报告。您从三个数据源收集了偏好数据——"GlobalDrive Safety Institute"、"AutoTech Safety Alliance"以及"QuickScan Auto Review"。近期有人对数据的真实性提出了担忧,您被要求评估这些数据,找出是否存在不可靠的数据源。

automotive_df 是一个合并后的 DataFrame,已通过预先导入的 pandas 库加载,包含来自三个来源的数据。预先导入的 majority_vote 函数会为每个 'id' 生成一个类似字典的对象,内含该 'id' 的多数投票 (chosen, rejected) 配对。

本练习是课程的一部分

来自人类反馈的强化学习(RLHF)

查看课程

练习说明

  • 为给定数据源定义一个条件,用于统计其与多数投票不一致的一次情况。

交互式实操练习

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

def detect_unreliable_source(merged_df):
    df_majority = df.groupby('id').apply(majority_vote)
    disagreements = {source: 0 for source in df['source'].unique()}
    for _, row in df.iterrows():
        # Condition to find a disagreement with majority vote
        ____
    unreliable_source = max(disagreements, key=disagreements.get)
    return unreliable_source

disagreement = detect_unreliable_source(automotive_df)
print("Unreliable Source:", disagreement)
编辑并运行代码