[R] Issue with batch forecasting of Time series data

Manish Mukherjee m@ni@hmukherjee @ending from hotm@il@com
Fri Jun 1 19:20:50 CEST 2018


i have a weekly data for servers for 62 weeks. want to predict the cpu% for next 5 weeks.I am trying to forecast for many servers at once but with the code i am getting only one week of future forecast for all the servers. Also the week date for the predicted week is showing as the last week of the original data . Need help in two things How can i change the date for the predicted  week, and  how can i predict for more than one week.

R code.

input_data <- read.csv("input.csv", header= TRUE)
Products = unique(input_data["Server.Name"][,])
output = matrix(0,nrow=(length(Products)*(1)),ncol=7)
colnames(output) =

    "Hi_80 ",

for (i in Products) {

 train = head(input_data["PERCENT_USED"][input_data["Server.Name"]==i] , 90)

  train     = ts(train[1:(length(train))])

  fc1 = auto.arima(train)
  pred1 = forecast( fc1)
  fit1_acry   = accuracy(pred1)
  fc2 = ets(train)
  pred2 = forecast( fc2 )
  fit2_acry = accuracy(pred2 )

  MAPE = data.frame ( fit1_MAPE = fit1_acry[,'MAPE'],
                       fit2_MAPE = fit2_acry[,'MAPE']

  best =  which.min(MAPE)

  BestModel = get(paste('fc',best,sep=""))

  forecastoutput = rbind(data.frame(forecast(BestModel, h=1)) )
  forecast_date = rbind(tail(input_data["DATE"][input_data["Server.Name"]==i],(1)))
  row_index = which(Products==i)

  output[row_index,1]   = i
  output[row_index,2]   = forecast_date
  output[row_index,3]   = (round(forecastoutput$Point.Forecast,2))
  output[row_index,4]   = as.numeric(round(forecastoutput$Lo.80,2))
  output[row_index,5]   = as.numeric(round(forecastoutput$Hi.80,2))
  output[row_index,6]   = as.numeric(round(forecastoutput$Lo.95,2))
  output[row_index,7] = as.numeric(round(forecastoutput$Hi.95,2))
  output_onestep = data.frame(output)


	[[alternative HTML version deleted]]

More information about the R-help mailing list