R语言用rle,svm和rpart进行时间序列预测

下面显示了四种预测时间序列的方法。

支持向量机(R package e1071。“Chih-Chung Chang and Chih-Jen Lin,LIBSVM:a library for support vector machines,2005.”的实现)。

递归分区(R package rpart。“Breiman,Friedman,Olshen and Stone。Classification and Regression Trees,1984”的实现)。

将最后两种方法的性能与rle进行比较,得到svm的95%和rpart的94%。

# Apply rle (forward and backward) and a condition: lenght time for sleep changes of 1h m$rle(Xvar ='sleep',Xlmin =60)m$setZoo()# Show differences between conditional and conditional + rleplot(m$zo[,c(5,7,8)],type ='l')

# Subset a week

# Plot correlation matrix

w$correlation(Xvars =w$nm[c(2:7,9)])

# SVM and Recursive partitioning

plot(tune.gamma.cost)

rpart.p <- predict(rpart.m, data[,-1],type ='class')# Resultsdt$svm = as.integer(svm.p)dt$rpart = as.integer(rpart.p)plot(w$dt2zoo(dt)[,c(5,8,9,10)],type ='l')

可下载资源

关于作者

Kaizong Ye拓端研究室(TRL)的研究员。

本文借鉴了作者最近为《R语言数据分析挖掘必知必会 》课堂做的准备。

​非常感谢您阅读本文,如需帮助请联系我们!

 
QQ在线咨询
售前咨询热线
15121130882
售后咨询热线
0571-63341498

关注有关新文章的微信公众号


永远不要错过任何见解。当新文章发表时,我们会通过微信公众号向您推送。

技术干货

最新洞察

This will close in 0 seconds