oliyiyi 发表于 2015-12-5 16:34 
里面有足够多的实例程序,不知道你要的是不是这些
Classification
In this example, we use the glass data from the UCI Repository of Machine
Learning Databases for classification. The task is to predict the type of a glass
on basis of its chemical analysis. We start by splitting the data into a train and
test set:
> library(e1071)
> library(rpart)?
> data(Glass, package="mlbench")
> ## split data into a train and test set
> index <- 1:nrow(Glass)?
> testindex <- sample(index, trunc(length(index)/3))?
> testset <- Glass[testindex,]
> trainset <- Glass[-testindex,]
Both for the SVM and the partitioning tree (via rpart()), we fit the model and
try to predict the test set values:
> ## svm
> svm.model <- svm(Type ~ ., data = trainset, cost = 100, gamma = 1)
> svm.pred <- predict(svm.model, testset[,-10])?
是这个吗?我运行完了,怎么没有出现正确率之类的。还是这个是不完整的?打问号的是我不懂的地方,谢谢赐教了。