분석시각화 대회 코드 공유 게시물은
내용 확인 후
좋아요(투표) 가능합니다.
평가 산식 안내
이번 'SW중심대학 디지털 경진대회_SW와 생성AI의 만남: AI 부문'에 실제 적용되고 있는 평가 산식 코드를 공개합니다.
참가자 여러분들께서는 모델 성능 개선에 해당 평가 산식 코드를 활용하실 수 있습니다.
이번 산식은 여러 평가 지표를 조합하여 분류 문제에서의 모델의 예측 성능과 예측의 신뢰도를 함께 고려하여 평가하기 위해 구성되었습니다.
산식은 AUC(Area Under the Curve), Brier Score, ECE(Expected Calibration Error) 세 가지 주요 성능 지표를 결합합니다.
산식은 0 ~ 1 의 범위로 산출되며, 산식 점수가 0 에 가까울수록 좋은 모델 성능을 뜻합니다.
import numpy as np
from sklearn.calibration import calibration_curve
from sklearn.metrics import mean_squared_error
from sklearn.metrics import roc_auc_score
import pandas as pd
def expected_calibration_error(y_true, y_prob, n_bins=10):
prob_true, prob_pred = calibration_curve(y_true, y_prob, n_bins=n_bins, strategy='uniform')
bin_totals = np.histogram(y_prob, bins=np.linspace(0, 1, n_bins + 1), density=False)[0]
non_empty_bins = bin_totals > 0
bin_weights = bin_totals / len(y_prob)
bin_weights = bin_weights[non_empty_bins]
prob_true = prob_true[:len(bin_weights)]
prob_pred = prob_pred[:len(bin_weights)]
ece = np.sum(bin_weights * np.abs(prob_true - prob_pred))
return ece
def auc_brier_ece(answer_df, submission_df):
# Check for missing values in submission_df
if submission_df.isnull().values.any():
raise ValueError("The submission dataframe contains missing values.")
# Check if the number and names of columns are the same in both dataframes
if len(answer_df.columns) != len(submission_df.columns) or not all(answer_df.columns == submission_df.columns):
raise ValueError("The columns of the answer and submission dataframes do not match.")
submission_df = submission_df[submission_df.iloc[:, 0].isin(answer_df.iloc[:, 0])]
submission_df.index = range(submission_df.shape[0])
# Calculate AUC for each class
auc_scores = []
for column in answer_df.columns[1:]:
y_true = answer_df[column]
y_scores = submission_df[column]
auc = roc_auc_score(y_true, y_scores)
auc_scores.append(auc)
# Calculate mean AUC
mean_auc = np.mean(auc_scores)
brier_scores = []
ece_scores = []
# Calculate Brier Score and ECE for each class
for column in answer_df.columns[1:]:
y_true = answer_df[column].values
y_prob = submission_df[column].values
# Brier Score
brier = mean_squared_error(y_true, y_prob)
brier_scores.append(brier)
# ECE
ece = expected_calibration_error(y_true, y_prob)
ece_scores.append(ece)
# Calculate mean Brier Score and mean ECE
mean_brier = np.mean(brier_scores)
mean_ece = np.mean(ece_scores)
# Calculate combined score
combined_score = 0.5 * (1 - mean_auc) + 0.25 * mean_brier + 0.25 * mean_ece
return combined_score
answer_df = 실제 정답 df [id, fake(0 or 1), real(0 or 1)]
submission_df = 예측한 정답 df [id, fake(0~1), real(0~1)]
입니다.
질문할게 있습니다! 대회 마무리 되었는데 추후에 테스트 데이터에 대한 라벨은 따로 공개는 안해주시나요?
네, 평가 데이터(Test Data)에 대한 Ground-Truth는 공개하지 않습니다.
해당 대회는 대회가 종료되어도 '연습 제출'이 가능하며, 제출 시 Public 리더보드에만 반영되며
7/20 부터는 제출 탭에서 연습 제출한 제출물들의 Public / Private Score를 확인하실 수 있습니다.
데이콘(주) | 대표 김국진 | 699-81-01021
통신판매업 신고번호: 제 2021-서울영등포-1704호
직업정보제공사업 신고번호: J1204020250004
서울특별시 영등포구 은행로 3 익스콘벤처타워 901호
이메일 dacon@dacon.io |
전화번호: 070-4102-0545
Copyright ⓒ DACON Inc. All rights reserved
위 코드에서 answer_df 가 무엇을 뜻하는지 알 수 있을까요?