|
library(forecastxgb)
library(tseries)
library(forecast)
library(xgboost)
library(Matrix)
#
set.seed(2)
#棰勬祴鍑鸿?鍛ㄤ骇閲?
path <-"D:\\predict_pkg_startdate\\data2.csv"
data <- read.csv(path)
train <- ts(data$persons)
isholidayss <- matrix(data[,6],dimnames = list(NULL,"isholidays"))
model <- xgbar(y = train,
xreg = isholidayss,
nrounds = 100,
maxlag = max(8+2*frequency(train)),
nrounds_method = "manual",
verbose = FALSE
)
fc <- forecast(model,h = 10)
print(fc$mean)
predict_data <- matrix(fc$mean,ncol = 1,dimnames = list(NULL,"T_persons"))
write.csv(predict_data)
plot(fc)
报错如下:
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
|
|