신뢰할 수 없는 데이터 소스 식별
여러분의 팀은 자동차 안전 분야에서 정확한 보고서 생성을 지원하는 모델을 개발하고 있어요. 세 가지 데이터 소스, 즉 "GlobalDrive Safety Institute", "AutoTech Safety Alliance", "QuickScan Auto Review"에서 선호도 데이터를 수집했습니다. 최근 데이터 무결성에 대한 우려가 제기되어, 신뢰할 수 없는 데이터 소스가 있는지 평가해 달라는 요청을 받았습니다.
automotive_df는 미리 임포트된 pandas 라이브러리를 사용해 로드된 결합 DataFrame으로, 세 소스의 데이터를 포함하고 있어요. 미리 임포트된 majority_vote 함수는 각 'id'에 대해 다수결로 선택된 (chosen, rejected) 쌍을 담은 사전과 유사한 객체를 생성합니다.
이 연습은 강의의 일부입니다
Reinforcement Learning from Human Feedback (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)