hack-a-thon / src /utils.py
KuuwangE's picture
์ •์ƒํ™”
0c6d96d unverified
def evaluate_model(rmse, nmae=None, rmse_max=500, nmae_max=1.0):
"""
๋ชจ๋ธ ์„ฑ๋Šฅ ์ ์ˆ˜ํ™” ํ•จ์ˆ˜
- RMSE์™€ NMAE๋Š” ์ž‘์„์ˆ˜๋ก ์ข‹์Œ
- RMSE๋Š” [0, rmse_max], NMAE๋Š” [0, nmae_max] ๊ตฌ๊ฐ„์œผ๋กœ ์ •๊ทœํ™”
- NMAE๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ 0์  ์ฒ˜๋ฆฌ
- ์ตœ์ข… ์ ์ˆ˜๋Š” RMSE์™€ NMAE ์ ์ˆ˜์˜ ๋‹จ์ˆœ ํ‰๊ท 
Args:
rmse : float
๋ชจ๋ธ์˜ RMSE ๊ฐ’
nmae : float or None
๋ชจ๋ธ์˜ NMAE ๊ฐ’ (์—†์œผ๋ฉด None)
rmse_max : float
RMSE ์ตœ๋Œ€ ๊ธฐ์ค€๊ฐ’ (default=500)
nmae_max : float
NMAE ์ตœ๋Œ€ ๊ธฐ์ค€๊ฐ’ (default=1.0)
Return:
dict : {
"rmse_score": float,
"nmae_score": float,
"final_score": float
}
"""
# RMSE ์ ์ˆ˜ (0~100)
rmse_score = max(0, (1 - rmse / rmse_max) * 100)
# NMAE ์ ์ˆ˜ (0~100)
if nmae is not None:
nmae_score = max(0, (1 - nmae / nmae_max) * 100)
else:
nmae_score = 0
# ์ตœ์ข… ์ ์ˆ˜ = ๋‹จ์ˆœ ํ‰๊ท 
final_score = (rmse_score + nmae_score) / 2
return final_score
# return {
# "rmse": round(rmse_score, 2),
# "nmae": round(nmae_score, 2),
# "final": round(final_score, 2)
# }