7-classification-SVM

7-classification-SVM

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b+b0 =1 Margin 1/ ||b||2 Maximize Statistics 503, Spring 2013, ISU 23 <1%$*8$/=-2'/( 1.5 >x 1.0 x2 0.0 -1.0 -0.5 x2 0.5 x3 x1 o6 [1,] [2,] [3,] [4,] [5,] [6,] >y o4 o5 -1.0 0.0 0.5 1.0 1.5 x1 [1,] [2,] [3,] [4,] [5,] [6,] [,1] [,2] 0.3165760 0.4296047 0.2961924 1.4196359 1.6998790 0.7016387 -0.6023607 -0.6644422 -0.6348229 -1.1517504 -1.0754638 -0.7346868 [,1] 1 1 1 -1 -1 -1 Statistics 503, Spring 2013, ISU 24 1.5 <1%$*8$/=-2'/( 1.0 x2 x1 0.0 -1.0 -0.5 x2 0.5 x3 o6 o4 o5 -1.0 0.0 0.5 1.0 > x.svm <- svm(y~., data=df, kernel="linear") > x.svm$SV x1 x2 1 0.3165760 0.4296047 4 -0.6023607 -0.6644422 > x.svm$coefs [,1] [1,] 0.9797279 [2,] -0.9797279 1.5 x1 Statistics 503, Spring 2013, ISU 25 <1%$*8$/=-2'/( 9)6$.':;'!'<#6$/':;'5#$/=)'n >6=)'%:0='?&5@#0'<#6$/''0' =)#$'&5/:A6=)%'-:AA#0*:$B0'=:'%&C6%6"6$/ '''''''''''''''''''''''''''''''''''1T ! - !TH! 0@<D#-='=:'''''!i ! 0, !Ty=0, >)#A#'''''''''''Hij=yiyj (xiTxj), i,j=1, ..., n > + + > > + + calc.outprod <- function(x1, x2) { x1%*%t(x2) } calc.H <- function(x, y) { (y%*%t(y))*calc.dist(x, x) } Statistics 503, Spring 2013, ISU 26 1.5 <1%$* 8$/=-2'/( 1.0 x2 x1 0.0 -1.0 -0.5 x2 0.5 x3 o6 o4 o5 -1.0 0.0 0.5 x1 1.0 1.5 > # Consider all pairs of points from opposing groups > poss.vals <- NULL > for (i in 1:3) { + for (j in 4:6) { + alp <- rep(0, 6) + alp[i] <- 1; alp[j] <- 1 + poss.vals <- rbind(poss.vals, c(i, j, t(as.matrix(rep(1,6)))%*%alp - t(alp)%*%calc.H(x, y)%*%alp)) + } 1T ! - !TH! +} > poss.vals [,1] [,2] [,3] [1,] 1 4 -0.04138318 [2,] 1 5 -1.40584391 [3,] 1 6 -1.29334949 [4,] 2 4 -3.15077885 [5,] 2 5 -5.47881677 [6,] 2 6 -4.52254676 [7,] 3 4 -5.16648445 [8,] 3 5 -6.88588427 [9,] 3 6 -7.76555869 Statistics 503, Spring 2013, ISU 27 <1%$* 8$/=-2'/( 1.5 [0)'!=(1,0,0,1,0,0)T 1.0 x 0.0 o -1.0 -0.5 x2 0.5 x x o o -1.0 -0.5 0.0 0.5 1.0 1.5 x1 > b <- t(y*alp)%*%x >b [,1] [,2] [1,] 0.9189366 1.094047 > t(as.matrix(x.svm$coefs))%*%x.svm$SV x1 x2 [1,] 0.9003078 1.071868 > pt.on.line <...
View Full Document

This note was uploaded on 02/06/2014 for the course STAT 503 taught by Professor Staff during the Fall '08 term at Iowa State.

Ask a homework question - tutors are online