All pastes #783755 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-19 10:37 UTC
rendered paste body
attach(mix)
library(e1071)
x <- subset(mix, select = -class)
y <- class
plot (x, xlim=c(-3,5), ylim=c(-2,3), cex = 1.5, lwd = 2,main="Prediction by a a CART decision tree")
for (i in 1:200){
	if (class[i] == 1)
		points(var2[i]~var1[i],pch=21,col="red",cex=1.5,lwd=2)
	else
		points(var2[i]~var1[i],pch=21,col="green",cex=1.5,lwd=2)
}
modelSVM <- svm(x,y)
var1 <- c(1:10201)
z1 <- -3
var2 <- c(1:10201)
count <- 1
for (j in 1:101){
	z2 <- -2
	for (b in 1:101){
		var1[[count]] = z1
		var2[[count]] = z2
		z2 = z2 + 0.05
		count = count + 1
	}
	z1 = z1 + 0.08
}
xtest <- data.frame(var1,var2)
predSVM <- predict(modelSVM,xtest)
for (i in 1:10201){
	if (predSVM[i] == 1)
		points(var2[i]~var1[i],pch=20,col="red",cex=0.01,lwd=0.01)
	else
		points(var2[i]~var1[i],pch=20,col="green",cex=0.01,lwd=0.01)
}