๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“– Theory/AI & ML

[AI/ML] Precision, Recall, AP (Average Precision) ๊ฐ„๋‹จ ์„ค๋ช… | ๊ฐ์ฒด ๊ฒ€์ถœ ์„ฑ๋Šฅ ์ง€ํ‘œ

by ๋ญ…์ฆค 2023. 12. 8.
๋ฐ˜์‘ํ˜•

Object Detection(๊ฐ์ฒด ๊ฒ€์ถœ) ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์„ ์ธก์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Precision(์ •๋ฐ€๋„), Recall(์žฌํ˜„์œจ), ๊ทธ๋ฆฌ๊ณ  Average Precision(AP)๋ฅผ ๊ผญ ์•Œ์•„์•ผ ํ•œ๋‹ค. ML๋ฅผ ๊ณต๋ถ€ํ•˜๋‹ค ๋ณด๋ฉด ํ•œ ๋ฒˆ ์ด์ƒ์€ ๊ณต๋ถ€ํ•˜๋Š” ๊ฐœ๋…์ธ๋ฐ, ๋Š˜ ํ—ท๊ฐˆ๋ฆฌ๋Š” ๋ถ€๋ถ„์ด ์žˆ๊ธฐ์— ์ •๋ฆฌํ•ด ๋‘๋ ค ํ•œ๋‹ค. 

 

๊ฐ์ฒด ๊ฒ€์ถœ๊ณผ ์ž‘์—…์—์„œ๋Š” Precision, Recall ๋“ฑ์˜ ๊ฐœ๋…์ด ์ค‘์š”ํ•œ๋ฐ, ๊ทธ ์ด์œ ๋Š” ๊ฐ์ฒด ๊ฒ€์ถœ ์„ฑ๋Šฅ์ด ์ข‹์ง€์•Š์„ ๋•Œ ์˜ค๊ฒ€์ถœ์„ ๋งŽ์ด ํ–ˆ์„ ์ˆ˜๋„ ์žˆ๊ณ , ๊ฒ€์ถœ ์ž์ฒด๊ฐ€ ์ž˜ ์•ˆ๋์„ ์ˆ˜๋„(๋ฏธ๊ฒ€์ถœ) ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

์ด๊ฒŒ ์™œ ์ค‘์š”ํ• ๊นŒ? ๊ฐ์ฒด ๊ฒ€์ถœ ์ž‘์—…์— ๋”ฐ๋ผ ์˜ค๊ฒ€์ถœ์ด ์น˜๋ช…์ ์ธ ๊ฒฝ์šฐ๋„ ์žˆ๊ณ , ๋ฏธ๊ฒ€์ถœ์ด ์น˜๋ช…์ ์ธ ๊ฒฝ์šฐ๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

๋‹ค๋ฅธ ์„ค๋ช…๋“ค์„ ๋ณด๋ฉด True positive, False positive,... ๋“ฑ์˜ ๋ณต์žกํ•œ ๊ฐœ๋…์ด ๋งŽ์€๋ฐ ํ•œ ๋ฒˆ์”ฉ ์ดํ•ด๋Š” ํ•ด์•ผํ•œ๋‹ค. ํ•˜์ง€๋งŒ ๋” ์ค‘์š”ํ•œ ๊ฒƒ์€ precision๊ณผ recall์ด ๋†’๊ณ  ๋‚ฎ์Œ์— ๋”ฐ๋ผ ๋ฌด์—‡์ด ๋‹ค๋ฅธ์ง€๋ฅผ ์ดํ•ดํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์•„๋ž˜์—์„œ ํ•ด๋‹น ๋‚ด์šฉ์„ ์‚ดํŽด๋ณด์ž.


 

Precision (์ •๋ฐ€๋„)

  • ๋ชจ๋ธ์ด ์–‘์„ฑ์œผ๋กœ ์˜ˆ์ธกํ•œ ๊ฒƒ ์ค‘์—์„œ ์‹ค์ œ๋กœ ์–‘์„ฑ์ธ ๋น„์œจ
  • Precision = (True Positives) / (True Positives + False Positives)
  • Precision↑ : ๋ชจ๋ธ์ด ์˜ˆ์ธกํ•œ ์–‘์„ฑ์ด ๋Œ€๋ถ€๋ถ„ ์‹ค์ œ ์–‘์„ฑ / ์˜ค๊ฒ€์ถœ ์ ์Œ
  • Precision↓ : ๋ชจ๋ธ์ด ์–‘์„ฑ์œผ๋กœ ์˜ˆ์ธกํ•œ ๋Œ€๋ถ€๋ถ„์ด ์‹ค์ œ๋กœ๋Š” ์Œ์„ฑ / ์˜ค๊ฒ€์ถœ ๋‹ค์ˆ˜

 

 

Recall (์žฌํ˜„์œจ)

  • ์‹ค์ œ ์–‘์„ฑ ์ค‘์—์„œ ๋ชจ๋ธ์ด ์ •ํ™•ํ•˜๊ฒŒ ๊ฐ์ง€ํ•œ ๋น„์œจ
  • Recall = (True Positives) / (True Positives + False Negatives)
  • Recall↑ : ๋ชจ๋ธ์ด ๋Œ€๋ถ€๋ถ„์˜ ์‹ค์ œ ์–‘์„ฑ์„ ๊ฐ์ง€ / ๋ฏธ๊ฒ€์ถœ ์ ์Œ
  • Recall : ๋ชจ๋ธ์ด ์‹ค์ œ ์–‘์„ฑ ์ค‘ ์ผ๋ถ€๋ฅผ ๊ฐ์ง€ํ•˜์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ / ๋ฏธ๊ฒ€์ถœ ๋‹ค์ˆ˜

 

precision์ด ๋‚ฎ๋‹ค๋Š” ๊ฒƒ์€ ์˜ค๊ฒ€์ถœ์ด ๋งŽ๋‹ค๋Š” ๊ฒƒ์ด๊ณ , recall์ด ๋‚ฎ๋‹ค๋Š” ๊ฒƒ์€ ๋ฏธ๊ฒ€์ถœ์ด ๋งŽ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๋•Œ๋ฌธ์— ์ผ๋ฐ˜์ ์œผ๋กœ score thresholod์— ๋”ฐ๋ผ precision๊ณผ recall์€ ๋ฐ˜๋น„๋ก€ ๊ด€๊ณ„๊ฐ€ ๋œ๋‹ค. ๋งŽ์ด ๊ฒ€์ถœํ•˜๋‹ค ๋ณด๋ฉด ๋ฏธ๊ฒ€์ถœ์€ ์ ์–ด์ง€์ง€๋งŒ ์˜ค๊ฒ€์ถœ์ด ๋งŽ์•„์ง€๊ณ , ๋ณด์ˆ˜์ ์œผ๋กœ ๊ฒ€์ถœํ•˜๋‹ค๋ณด๋ฉด ์˜ค๊ฒ€์ถœ์€ ์ ์–ด์ง€๋ฏธ๋งŒ ๋ฏธ๊ฒ€์ถœ์ด ๋งŽ์•„์ง€๋‹ˆ๊นŒ. 

๋•Œ๋ฌธ์— ๊ฐ์ฒด ๊ฒ€์ถœ์—์„œ๋Š” precision๊ณผ recall์ด ๋ชจ๋‘ ์ค‘์š”ํ•˜๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ๊ฐ€์žฅ ์ข‹์€ ๋ชจ๋ธ์„ ๊ณ ๋ฅด๊ธฐ ์œ„ํ•ด์„  ์–ด๋–ค ์ง€ํ‘œ๋ฅผ ๋ด์•ผํ• ๊นŒ? ์•„๋ž˜์˜ Average Precision์„ ๋ณด์ž.

 

 

 

 

AP (Average Precision)

  • Precision-Recall ๊ณก์„ (์–‘์„ฑ ์˜ˆ์ธก์˜ Precision๊ณผ Recall ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ณก์„ ) ์•„๋ž˜์˜ ๋ฉด์ 
  • AP๋Š” ๋ชจ๋ธ์ด ์–ด๋–ค Recall ๊ฐ’์—์„œ ์–ผ๋งˆ๋‚˜ ์ข‹์€ ์„ฑ๋Šฅ์„ ๋ณด์ด๋Š”์ง€๋ฅผ ์ธก์ •ํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ Recall ๊ฐ’์— ๋Œ€ํ•œ AP๋ฅผ ํ‰๊ท ๋‚ด๋ฉด ๋ชจ๋ธ์˜ ์ „๋ฐ˜์ ์ธ ์„ฑ๋Šฅ์„ ์ธก์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋ชจ๋ธ์˜ ์ ์ ˆํ•œ precision-recall ๋น„์œจ์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด Score Threshold ๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•œ๋ฐ, ์ด ๊ณผ์ • ์ „์— ์–ด๋–ค ๋ชจ๋ธ ์›จ์ดํŠธ๋ฅผ ์„ ํƒํ• ์ง€๊ฐ€ ์„ ํ–‰๋˜์–ด์•ผ ํ•œ๋‹ค. ์ด ๋•Œ ์ผ๋ฐ˜์ ์œผ๋กœ AP๊ฐ€ ๋†’์€ ๋ชจ๋ธ์„ ์„ ํƒํ•œ๋‹ค.

 

์ด์ฒ˜๋Ÿผ Precision, Recall, AP๋Š” ๊ฐ์ฒด ๊ฒ€์ถœ ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์„ ์ข…ํ•ฉ์ ์œผ๋กœ ํ‰๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค. ๊ณ ์ •๋œ Threshold์—์„œ ์ธก์ •๋˜๋Š” Precision๊ณผ Recall์€ ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์„ ํŠน์ •ํ•œ ์กฐ๊ฑด์—์„œ ํ‰๊ฐ€ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋ฉฐ, AP๋Š” ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์„ ๋‹ค์–‘ํ•œ Threshold ๊ฐ’์—์„œ ํ‰๊ท ํ™”ํ•˜์—ฌ ์ธก์ •ํ•œ ๊ฐ’์ด๋‹ค. AP๊ฐ€ ๋†’์„์ˆ˜๋ก ๋ชจ๋ธ์ด ๋†’์€ precision์™€ recall์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ํ•ด์„๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•„๋‘์ž.

๋ฐ˜์‘ํ˜•