[Linear Classification] part 4 - 2

2023. 1. 19. 10:43
๐Ÿง‘๐Ÿป‍๐Ÿ’ป์šฉ์–ด ์ •๋ฆฌ

zero-one loss
hinge loss
cross-entropy loss

Linear Classification

 

 

hinge loss

Hinge Loss

 

Hinge Loss Formula

 

๊ณ„์‚ฐ ๊ฐ’์ด + ๊ฐ’์ด ๋œ๋‹ค๋ฉด, max ๊ฐ’์€ margin ๊ฐ’์— ์„ ํ˜•์ ์œผ๋กœ ๋น„๋ก€ํ•˜์—ฌ ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

 

์ด ๊ฒฝ์šฐ, loss ์—ญ์‹œ ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

 

 

Cross-entropy loss

 

Cross-entropy loss

 

p์™€ q๊ฐ€ ์œ ์‚ฌํ•˜๋‹ค๋ฉด loss๋Š” ์ค„์–ด๋“ค๊ณ , ์„œ๋กœ ๋‹ค๋ฅด๋‹ค๋ฉด loss๋Š” ์˜ฌ๋ผ๊ฐ‘๋‹ˆ๋‹ค.

 

 

์ง€๊ธˆ๊นŒ์ง€๋Š” ๊ณ„์‚ฐํ•œ ๋ชจ๋ธ์˜ score ๊ฐ’์€ ์‹ค์ˆ˜ ๊ฐ’์ž…๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿฌ๋‚˜ ๋ฐฉ๊ธˆ ๋ฐฐ์šด Cross-entropy loss ๊ฐ’์€ ํ™•๋ฅ  ๊ฐ’์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋ ‡๋‹ค๋ฉด ๊ณ„์‚ฐํ•œ Score ๊ฐ’์€ ์–ด๋–ป๊ฒŒ ์ด๋Ÿฌํ•œ ํ™•๋ฅ  ๊ฐ’์œผ๋กœ mapping ํ•  ์ˆ˜๊ฐ€ ์žˆ์„๊นŒ์š”?

 

 

์šฐ๋ฆฌ๊ฐ€ fittingํ•˜๊ณ ์ž ํ•˜๋Š” Label์€ 1 or 0 ์ธ ๊ฐ’์„ ๊ฐ–๊ฒŒ ๋˜๋Š”๋ฐ, ์šฐ๋ฆฌ์˜ score๋Š” ์‹ค์ˆ˜ ๊ฐ’์ด๊ธฐ ๋•Œ๋ฌธ์—,

 

๊ทธ ์‹ค์ˆ˜ ๊ฐ’์„ ํ™•๋ฅ  ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด์„œ mappingํ•ด์•ผ ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

์ด mapping์— ์‚ฌ์šฉํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ ๋ฐ”๋กœ,

Sigmoid

ํ•จ์ˆ˜ ์ž…๋‹ˆ๋‹ค.

 

Sigmoid

 

์ด ํ•จ์ˆ˜์˜ ๊ฐœํ˜•์„ ์‚ดํ”ผ์–ด real ๊ฐ’์ด +๋กœ ๊ต‰์žฅํžˆ ์ฆ๊ฐ€ํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด ํ™•๋ฅ  ๊ฐ’ 1์— ๊ทผ์‚ฌํ•˜๊ฒŒ ๋  ๊ฒƒ์ด๋ฉฐ, 

 

๋ฐ˜๋Œ€๋กœ -๋กœ ์ปค์ง€๊ฒŒ ๋œ๋‹ค๋ฉด ํ™•๋ฅ  ๊ฐ’ 0์— ๊ทผ์‚ฌํ•˜๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

real์ด 0์˜ ๊ฐ’์„ ๊ฐ€์ง€๊ฒŒ ๋˜๋ฉด ์ด ๊ฐ’์€ 1/2์˜ ํ™•๋ฅ ์„ ๊ฐ–๋Š” ํ•จ์ˆ˜๊ฐ€ ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

๊ทธ๋Ÿฌ๋ฏ€๋กœ, ์šฐ๋ฆฌ์˜ Score ์‹ค์ˆ˜ ๊ฐ’์„ 0๋ถ€ํ„ฐ 1 ์‚ฌ์ด์˜ ๊ฐ’์œผ๋กœ mapping ํ•  ์ˆ˜๊ฐ€ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ด๋Ÿฌํ•œ ํ˜•ํƒœ๋ฅผ ์šฐ๋ฆฌ๊ฐ€ logistic model์ด๋ผ๊ณ  ์ด์•ผ๊ธฐ ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

Linear classifier๋ฅผ ํ•™์Šตํ•˜๋Š” ๋ฐ ์žˆ์–ด, ์–ด๋–ป๊ฒŒ Gradient Descent Algorithm์ด ์“ฐ์ผ๊นŒ?

 

1. weight ๊ฐ’ initialization

2. gradient ๊ฐ’ ๊ณ„์‚ฐ

์ฆ‰, cross-entropy loss์˜, train loss์˜ ๋ฏธ๋ถ„ term์ด ๋ฉ๋‹ˆ๋‹ค.

3. weight update

4. ์ˆ˜๋ ดํ•  ๋•Œ๊นŒ์ง€ ์ง„ํ–‰

 

 

 

'Artificial Intelligence' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Advanced Classification] part 5 - 1  (0) 2023.01.19
[Linear Classification] part 4 - 3  (0) 2023.01.19
[Linear Classification] part 4 - 1  (2) 2023.01.19
[Parameter] part 3 - 2  (0) 2023.01.16
[Gradient Descent] part 3 - 1  (0) 2023.01.16

BELATED ARTICLES

more