Information Technology Reference
In-Depth Information
# Check accuracy:
table(pred, y)
# compute decision values and probabilities:
pred <
predict(model, x, decision.values = TRUE)
-
attr(pred,
)[1:4,]
# visualize (classes by color, SV by crosses):
plot(cmdscale(dist(iris,[
decision.values
5])),
col = as.integer(iris,[5]),
pch = c(
)[1:150 tune 53
## try regression mode on two dimensions
# create data
x<
o
,
+
seq (0.1, 5, by = 0.05)
-
y<
log(x) + rnorm(x, sd = 0.2)
# estimate model and predict input values
m<
-
-
svm(x, y)
new <
predict(m, x)
# visualize
plot(x, y)
points(x, log(x), col = 2)
points(x, new, col = 4)
## density-estimation
# create 2-dim. normal with rho = 0:
X<
-
data.frame(a = rnorm(1000), b = rnorm(1000))
attach(X)
# traditional way:
m<
-
svm(X, gamma = 0.1)
# formula interface:
m<
-
svm(
., data = X, gamma = 0.1)
-
*
# or:
m<
svm(
a + b, gamma = 0.1)
-
*
# test:
newdata <
data.frame(a = c(0, 4), b = c(0, 4))
predict (m, newdata)
# visualize:
plot(X, col = 1:1000 points(newdata, pch =
-
+
, col = 2, cex = 5)
# weights: (example not particularly sensible)
i2 <
iris
levels(i2$Species)[3] <
-
-
versicolor
summary(i2$Species)
wts <
-
100 /table(i2$Species)
wts
m<
-
svm(Species
*
., data = i2, class.weights = wts)
Search WWH ::




Custom Search