File size: 1,206 Bytes
0c6d96d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)
    # }