R语言用rlesvm和rpart决策树进行时间序列预测

4次阅读

共计 748 个字符,预计需要花费 2 分钟才能阅读完成。

原文链接:http://tecdat.cn/?p=3072


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

支持向量机(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%。

R:

# 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')

正文完
 0