開始使用免費開始

不可靠資料來源辨識

你的團隊正在開發一個模型,協助汽車安全產業產出準確的報告。你從三個資料來源蒐集了偏好資料——「GlobalDrive Safety Institute」、「AutoTech Safety Alliance」以及「QuickScan Auto Review」。最近外界對資料的可信度產生疑慮,你被要求評估是否存在任何不可靠的資料來源。

automotive_df 是使用已預先匯入的 pandas 函式庫載入並合併的 DataFrame,其中包含這三個來源的資料。已預先匯入的 majority_vote 函式會依 'id' 產生一個類似字典的物件,內含該 id 的多數決(chosen, rejected)配對。

本練習屬於課程

Reinforcement Learning from Human Feedback(RLHF)

檢視課程

練習說明

  • 定義條件,用於在指定資料來源中,計算與多數決不一致的 1 次情況。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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)
編輯並執行程式碼