R에서 지원 벡터 회귀를 사용하여 미래의 에너지 소비를 예측하고 싶습니다.이 코드는 있지만 정확한 날씨인지는 확실하지 않습니다.지원 벡터 회귀를 사용하여 예측하기 R
`#gathering the data
data<-read.csv("C:\\2003_smd_hourly.csv",header=TRUE) #these are the values which are used to train the given model#
data
#data1<-read.csv("C:\\pr.csv",header=TRUE)#this file/ddata is used for checking the accuracy of prediction#
#data1
#y1<-data1[,15]
#x0<-data1[,2]
y<-data[,15] #sysload
x1<-data[,2] #houroftheday
x2<-data[,13] #drybulb temp(actualtemp)
x3<-data[,14] #dewpnttemp
#train<-sample(744,447)
#train
library(e1071)
model<-svm(y~x1+x2+x3,data=data[1:48,],cost=2.52*10^11,epsilon=0.0150,gamma=1)
model
#pr<-data[-train,]
#pr
predict1<-predict(model,newdata=data[49:72,])
predict1
par(mfrow=c(2,2))
plot(x1,y,col="red",pch=4)
#par(new=TRUE)
plot(x1,predict1,col="blue",pch=5) #plotting the values that have been predicted
#par(new=TRUE)
plot(x0,y1,col="black",pch=1)
error=y1-predict1
error
mae <- function(error)
{
mean(abs(error))
}
mae(error)
error <- y1 - predict1
error
rmse <- function(error)
{
sqrt(mean(error^2))
}
svrPredictionRMSE <- rmse(error)
svrPredictionRMSE
max(error)
min(error)
mape <- function(y1,predict1)
mape
mean(abs((y1 - predict1)/y1))*100
mape
는`예는 : 데이터는 여기 http://pastebin.com/MUfWFCPM
이미 어떤 코드가 있습니까? – blacksite
이 코드입니다. 저는 48 개의 값을 사용하여 모델을 훈련 시켰습니다. 그러나 모델이 24 개의 값만 예측하도록하고 싶습니다. –
데이터를 입력하는 데 사용하고있는 현재의 방법에 대해서는 조언 할 것입니다. 두 개의'data.frames'를 설정하고 훈련과 테스트/밸리데이션 세트를 제공하고'predict'를 호출 한 다음 두 번째'data.frame'을 사용할 때 교육 세트 만 제공합니다. 현재 메소드에는 사용자 환경에 중복 정보가 있습니다. – zacdav