support vector machines svms lecture 5
play

Support vector machines (SVMs) Lecture 5 David Sontag - PowerPoint PPT Presentation

Support vector machines (SVMs) Lecture 5 David Sontag New York University So5 margin SVM w . x + b = +1 w . x + b = 0 w . x + b =


  1. Support ¡vector ¡machines ¡(SVMs) ¡ Lecture ¡5 ¡ David ¡Sontag ¡ New ¡York ¡University ¡

  2. So5 ¡margin ¡SVM ¡ w . x ¡+ ¡b ¡= ¡+1 ¡ w . x ¡+ ¡b ¡= ¡0 ¡ w . x ¡+ ¡b ¡= ¡-­‑1 ¡ “slack ¡variables” ¡ ξ 1 ξ 3 ξ 2 Slack ¡penalty ¡ C > 0 : ¡ • C = ∞ � ¡minimizes ¡upper ¡bound ¡on ¡0-­‑1 ¡loss ¡ • C ≈ 0 � ¡ ¡points ¡with ¡ ξ i =0 ¡have ¡big ¡margin ¡ ξ 4 • ¡Select ¡using ¡cross-­‑valida=on ¡ Support ¡vectors: ¡ Data ¡points ¡for ¡which ¡the ¡constraints ¡are ¡binding ¡ ¡

  3. So5 ¡margin ¡SVM ¡ QP ¡form: ¡ More ¡“natural” ¡form: ¡ Equivalent ¡if ¡ RegularizaNon ¡ Empirical ¡loss ¡ term ¡

  4. Subgradient ¡ (for ¡non-­‑differenNable ¡funcNons) ¡

  5. (Sub)gradient ¡descent ¡of ¡SVM ¡objecNve ¡ Step ¡size: ¡ -­‑ ¡

  6. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡ For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡ η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direcNon, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡(1-­‑η t λ) ¡w t ¡+ ¡η t ¡y j ¡x j ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡(1-­‑η t λ) ¡w t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡

  7. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡ For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direcNon, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡η t (λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡ – ¡η t λw t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡

  8. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡ η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direcNon, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡η t (λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡η t λw t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡ Convergence ¡choice ¡: ¡Fixed ¡number ¡of ¡itera=ons ¡ ¡ ¡ ¡ ¡ ¡ ¡T=20*|data| ¡

  9. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡ Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direcNon, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡ η t (λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡ η t λw t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡ Stepsize ¡choice: ¡-­‑ ¡Ini=alize ¡with ¡1/λ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡-­‑ ¡Decays ¡with ¡1/t ¡

  10. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡ η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direc=on, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡η t ( λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡ – ¡η t λw t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡ Direc=on ¡choice: ¡ ¡Stochas=c ¡approx ¡to ¡the ¡subgradient ¡

  11. Subgradient ¡calculaNon ¡ λ 2 || w || 2 + 1 Objec=ve: ¡ X max { 0 , 1 − y i w · x i } m i λ 2 || w || 2 + max { 0 , 1 − y i w · x i } Stochas=c ¡Approx: ¡ For ¡a ¡randomly ¡chosen ¡data ¡point ¡ i ¡ (in ¡the ¡assignment ¡the ¡choice ¡of ¡i ¡is ¡ not ¡random ¡-­‑ ¡ easier ¡ to ¡debug ¡and ¡compare ¡between ¡students). ¡

  12. Subgradient ¡calculaNon ¡ λ 2 || w || 2 + 1 Objec=ve: ¡ X max { 0 , 1 − y i w · x i } m i λ 2 || w || 2 + max { 0 , 1 − y i w · x i } Stochas=c ¡Approx: ¡ (sub)gradient: ¡ λ || w || + d dw max { 0 , 1 − y i w · x i }

  13. Subgradient ¡calculaNon ¡ λ 2 || w || 2 + 1 Objec=ve: ¡ X max { 0 , 1 − y i w · x i } m i λ 2 || w || 2 + max { 0 , 1 − y i w · x i } Stochas=c ¡Approx: ¡ 0 ¡ y i w · x i (sub)gradient: ¡ 0 ¡ 1 ¡ λ || w || + d dw max { 0 , 1 − y i w · x i } y i w · x i <1 ¡ >1 ¡ =1 ¡ 0 − y i x i

  14. Subgradient ¡calculaNon ¡ λ 2 || w || 2 + 1 Objec=ve: ¡ X max { 0 , 1 − y i w · x i } m i λ 2 || w || 2 + max { 0 , 1 − y i w · x i } Stochas=c ¡Approx: ¡ 0 ¡ y i w · x i (sub)gradient: ¡ 0 ¡ 1 ¡ λ || w || + d dw max { 0 , 1 − y i w · x i } y i w · x i <1 ¡ >1 ¡ =1 ¡ 0 0 − y i x i

  15. Subgradient ¡calculaNon ¡ λ 2 || w || 2 + 1 Objec=ve: ¡ X max { 0 , 1 − y i w · x i } m i λ 2 || w || 2 + max { 0 , 1 − y i w · x i } Stochas=c ¡Approx: ¡ (sub)gradient: ¡ if y i w · x i < 1 λ w − y i x i else λ w + 0

  16. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡For ¡ j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡ η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direc=on, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡Go! ¡ ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡– ¡η t (λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡w t+1 ¡= ¡w t ¡ – ¡η t (λwt ¡ + ¡0) ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡ Direc=on ¡choice: ¡ ¡Stochas=c ¡approx ¡to ¡the ¡subgradient ¡ if y i w · x i < 1 λ w − y i x i else λ w + 0

  17. The ¡Pegasos ¡Algorithm ¡ General ¡framework ¡ Pegasos ¡Algorithm ¡(from ¡homework) ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ Ini=alize: ¡ w 1 ¡= ¡0, ¡t=0 ¡ For ¡iter ¡= ¡1,2,…,20 ¡ While ¡not ¡converged ¡ ¡For ¡j=1,2,…,|data| ¡ ¡t ¡= ¡t+1 ¡ ¡ ¡t ¡= ¡t+1 ¡ ¡Choose ¡a ¡stepsize, ¡η t ¡ ¡ ¡ η t ¡= ¡1/(tλ) ¡ ¡Choose ¡a ¡direcNon, ¡ p t ¡ ¡ ¡ If ¡y j (w t ¡x j ) ¡< ¡1 ¡ ¡ Go! ¡ ¡ ¡ ¡ ¡ w t+1 ¡= ¡w t ¡– ¡η t (λw t -­‑ ¡ ¡y j x j ) ¡ ¡Test ¡for ¡convergence ¡ ¡ ¡ Else ¡ ¡ ¡ ¡ w t+1 ¡= ¡w t ¡– ¡η t λw t ¡ Output: ¡wt+1 ¡ Output: ¡wt+1 ¡ Go: ¡ ¡update ¡w t+1 ¡= ¡w t ¡-­‑ ¡η t p t ¡

  18. Why ¡is ¡this ¡algorithm ¡interesNng? ¡ • Simple ¡to ¡implement, ¡state ¡of ¡the ¡art ¡results. ¡ – NoNce ¡similarity ¡to ¡Perceptron ¡algorithm! ¡ Algorithmic ¡differences: ¡ updates ¡if ¡insufficient ¡ margin, ¡scales ¡weight ¡vector, ¡and ¡has ¡a ¡learning ¡rate. ¡ • Since ¡based ¡on ¡ stochas7c ¡ gradient ¡descent, ¡its ¡ running ¡Nme ¡guarantees ¡are ¡probabilisNc. ¡ • Highlights ¡interesNng ¡tradeoffs ¡between ¡running ¡ Nme ¡and ¡data. ¡

  19. Much ¡faster ¡than ¡previous ¡methods ¡ • 3 ¡datasets ¡(provided ¡by ¡Joachims) ¡ – Reuters ¡CCAT ¡(800K ¡examples, ¡47k ¡features) ¡ – Physics ¡ArXiv ¡(62k ¡examples, ¡100k ¡features) ¡ – Covertype ¡(581k ¡examples, ¡54 ¡features) ¡ Pegasos SVM-Perf SVM-Light 2 77 20,075 Training ¡Time ¡ Reuters (in ¡seconds): ¡ 6 85 25,514 Covertype 2 5 80 Astro-Physics

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend