设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 1936|回复: 1

求教:forecastxgb预测碰到问题

[复制链接]
发表于 2017-8-30 21:04:16 | 显示全部楼层 |阅读模式
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

回复

使用道具 举报

发表于 2017-9-5 15:19:04 | 显示全部楼层
数据的格式,贴一下!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-20 19:34 , Processed in 0.023429 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表