Demo entry 6687514

RCORD

   

Submitted by anonymous on Dec 28, 2017 at 18:57
Language: RConsole. Code size: 600 Bytes.

 model_svm<-svm(Ot~., train,gamma=0.01,cost=100)
   summary(model_svm)#返回模型中的参数结果
   #将预测模型应用于测试数据,测试模型的预测精度
   preds1<-predict(model_svm, test)
   plot(preds1~ test$Ot)#画出真实值与预测值之间的散点图
   plot(preds1,pch=1,cex=0.5,col='red')#画出预测值对真实值的拟合图
   points(test$Ot,col='blue',pch=3,cex=0.5)
   legend("topleft",c("preds1","test$Ot"),lty=c(1,2),pch=c(1,3),col=c("red","blue"))
   #计算相对误差
   nmse1<-mean((preds1-test$Ot)^2)/mean((mean(test$Ot)-(test$Ot)^2))nmse1
   erro<-test$Ot-preds1#计算预测误差
   plot(erro)
   ##最大误差为:
   max(abs(erro)/abs(test$Ot))
   ##平均误差:
   mean(abs(erro)/abs(test$Ot)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).