require(e1071)
## Loading required package: e1071

Daten

iris2 <- read.csv("./17.18.statlearn.P3.data.csv",header=F)
iris2[,3] <- as.factor(iris2[,3])

Training

model.svm <- svm(as.formula("V3 ~ V2+V1"), data=iris2,type="C-classification",kernel="polynomial",degree=5,coef0=1,cost=100)

finale Hypothese

model.svm
## 
## Call:
## svm(formula = as.formula("V3 ~ V2+V1"), data = iris2, type = "C-classification", 
##     kernel = "polynomial", degree = 5, coef0 = 1, cost = 100)
## 
## 
## Parameters:
##    SVM-Type:  C-classification 
##  SVM-Kernel:  polynomial 
##        cost:  100 
##      degree:  5 
##       gamma:  0.5 
##      coef.0:  1 
## 
## Number of Support Vectors:  11
plot(model.svm,data=iris2)

Confusion Matrix

yhat <- predict(model.svm,iris2[,1:2])
table(estimated=yhat,true=iris2[,3])
##          true
## estimated -1  1
##        -1 50  0
##        1   0 50

Supportvektoren

model.svm$index
##  [1]  11  21  23  28  34  72  77  89  92  97 100
model.svm$coefs
##               [,1]
##  [1,]    0.1296787
##  [2,]  100.0000000
##  [3,]  100.0000000
##  [4,]    7.1999058
##  [5,]   74.0332135
##  [6,]  -26.2196626
##  [7,]  -89.0516869
##  [8,] -100.0000000
##  [9,]   -2.4658014
## [10,]  -53.1903307
## [11,]  -10.4353164

Es sind 11 Supportvektoren, 8 marginale, 3 nicht-marginale.