Driver Cognitive Data for Traffic Accident Risk Prediction AI Competition

Algorithm | Code Submission Evaluation | Tabular | Regression | Data Analysis | AUC | Brier Score | ECE

  • moneyIcon 60,000,000 KRW
  • 1,595 Users Completed
Closed

 

평가 산식 안내

2025.10.13 09:27 2,711 Views

이번 '운수종사자 인지적 특성 데이터를 활용한 교통사고 위험 예측 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


Previous
A검사(신규 자격 검사) 명세 안내
Competition - 운수종사자 인지적 특성 데이터를 활용한 교통사고 위험 예측 AI 경진대회
Likes 6
Views 3,355
Comments 0
6달 전
Current
평가 산식 안내
Competition - 운수종사자 인지적 특성 데이터를 활용한 교통사고 위험 예측 AI 경진대회
Likes 3
Views 2,711
Comments 0
6달 전
Next
No Next Post